From 0a315e79dfd60fb6c8c449b056b9558ae4611d65 Mon Sep 17 00:00:00 2001 From: Garance A Drosehn Date: Fri, 1 Jun 2001 00:07:09 +0000 Subject: [PATCH] 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 --- bin/sh/eval.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bin/sh/eval.c b/bin/sh/eval.c index 8bf2d84522d..3ea2626a3b8 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);