summaryrefslogtreecommitdiffstats
path: root/bin/sh
diff options
context:
space:
mode:
authorcracauer <cracauer@FreeBSD.org>2003-12-28 02:05:12 +0000
committercracauer <cracauer@FreeBSD.org>2003-12-28 02:05:12 +0000
commit853a4ae85d691a2f3500efc16c2eab14e3c117b0 (patch)
tree0d471e13dfc235ee10f22f987870187f57a1b9ff /bin/sh
parenta58bddbe366329e88f05c837f6874cc20db6a2cb (diff)
downloadFreeBSD-src-853a4ae85d691a2f3500efc16c2eab14e3c117b0.zip
FreeBSD-src-853a4ae85d691a2f3500efc16c2eab14e3c117b0.tar.gz
PR 28852
sh -e behaviour was incorrect when && and || statements where used in "if" clauses. This is the patch submitted by MORI Kouji <mori@tri.asanuma.co.jp>. It fixes the issue at hand, but sh fixes like this are super-hard to verify that they don't break anything else. I ran some of my old test cases and a few big GNU configure scripts that detected mistakes before, with the previous sh, patched sh and bash. No differences in behaviour found. MFC recommended after longer than usual time. Compiles on i386 and sledge.
Diffstat (limited to 'bin/sh')
-rw-r--r--bin/sh/eval.c25
1 files changed, 1 insertions, 24 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c
index 412f650..aab2a53 100644
--- a/bin/sh/eval.c
+++ b/bin/sh/eval.c
@@ -205,7 +205,6 @@ evaltree(union node *n, int flags)
case NAND:
evaltree(n->nbinary.ch1, EV_TESTED);
if (evalskip || exitstatus != 0) {
- flags |= EV_TESTED;
goto out;
}
evaltree(n->nbinary.ch2, flags);
@@ -246,25 +245,9 @@ evaltree(union node *n, int flags)
break;
case NFOR:
evalfor(n);
- /*
- * The 'for' command does not set exitstatus, so the value
- * now in exitstatus is from the last command executed in
- * the 'for' loop. That exit value had been tested (wrt
- * 'sh -e' checking) while processing that command, and
- * it should not be re-tested here.
- */
- flags |= EV_TESTED;
break;
case NCASE:
evalcase(n, flags);
- /*
- * The 'case' command does not set exitstatus, so the value
- * now in exitstatus is from the last command executed in
- * the 'case' block. That exit value had been tested (wrt
- * 'sh -e' checking) while processing that command, and
- * it should not be re-tested here.
- */
- flags |= EV_TESTED;
break;
case NDEFUN:
defun(n->narg.text, n->narg.next);
@@ -289,14 +272,8 @@ evaltree(union node *n, int flags)
out:
if (pendingsigs)
dotrap();
- /*
- * XXX - Like "!(n->type == NSEMI)", more types will probably
- * need to be excluded from this test. It's probably better
- * to set or unset EV_TESTED in the loop above than to bloat
- * the conditional here.
- */
if ((flags & EV_EXIT) || (eflag && exitstatus
- && !(flags & EV_TESTED) && !(n->type == NSEMI)))
+ && !(flags & EV_TESTED) && (n->type == NCMD)))
exitshell(exitstatus);
}
OpenPOWER on IntegriCloud