patch from oksh (except manpage, I'll merge that later):

pass "xerrok" status across the execution call stack to more closely
match what both POSIX and [18]ksh.1 already describe in regards to set
-e/errexit's behavior in determining when to exit from nonzero return
values.

specifically, the truth values tested as operands to &&' and ||', as
well as the resulting compound expression itself, along with the truth
value resulting from a negated command (i.e. a pipeline prefixed !'),
should not make the shell exit when -e is in effect.

issue reported by matthieu.
testing matthieu, naddy.
ok miod (earlier version), otto.
man page ok jmc.
This commit is contained in:
tg
2009-03-22 17:47:38 +00:00
parent 0fe20ab25f
commit b20f49adae
6 changed files with 66 additions and 54 deletions

6
eval.c
View File

@ -1,8 +1,8 @@
/* $OpenBSD: eval.c,v 1.33 2007/08/02 11:05:54 fgsch Exp $ */
/* $OpenBSD: eval.c,v 1.34 2009/01/29 23:27:26 jaredy Exp $ */
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.52 2009/03/14 18:12:51 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.53 2009/03/22 17:47:35 tg Exp $");
#ifdef MKSH_SMALL
#define MKSH_NOPWNAM
@ -1069,7 +1069,7 @@ comsub(Expand *xp, const char *cp)
ksh_dup2(pv[1], 1, false);
close(pv[1]);
}
execute(t, XFORK|XXCOM|XPIPEO);
execute(t, XFORK|XXCOM|XPIPEO, NULL);
restfd(1, ofd1);
startlast();
xp->split = 1; /* waitlast() */