summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorgad <gad@FreeBSD.org>2001-06-01 00:07:09 +0000
committergad <gad@FreeBSD.org>2001-06-01 00:07:09 +0000
commit1246730a2adf4ffe51c56fa7ffd478f89447fa62 (patch)
treea9c3ff619ab3da34135372ae80351a578fedd499 /bin
parent5eae83e2d821d3dfd529744226397fee133f4c17 (diff)
downloadFreeBSD-src-1246730a2adf4ffe51c56fa7ffd478f89447fa62.zip
FreeBSD-src-1246730a2adf4ffe51c56fa7ffd478f89447fa62.tar.gz
Fix how /bin/sh handles 'for' and 'case' statements when it is called to do
errexit (-e) processing. This solves a problem where 'make clean' would fail with an unspecified error in certain automake-generated makefiles. Reviewed by: no objections from -hackers... MFC after: 2 weeks
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/eval.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c
index 8bf2d84..3ea2626 100644
--- a/bin/sh/eval.c
+++ b/bin/sh/eval.c
@@ -249,9 +249,25 @@ evaltree(n, 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);
OpenPOWER on IntegriCloud