From ea5e582b96e1d9ae20a4dfb62eb1f7235c71694d Mon Sep 17 00:00:00 2001 From: stefanf Date: Sat, 10 Sep 2005 07:41:36 +0000 Subject: Exit the shell if a pipeline that is not preceded by ! fails and set -e is active. Use a separate flag to avoid adding another condition to the if-statement at the end of evaltree(). Briefly reviewed by: cracauer --- bin/sh/eval.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'bin/sh/eval.c') diff --git a/bin/sh/eval.c b/bin/sh/eval.c index c468e81..a91f9db 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -182,6 +182,9 @@ evalstring(char *s) void evaltree(union node *n, int flags) { + int do_etest; + + do_etest = 0; if (n == NULL) { TRACE(("evaltree(NULL) called\n")); exitstatus = 0; @@ -219,6 +222,7 @@ evaltree(union node *n, int flags) break; case NSUBSHELL: evalsubshell(n, flags); + do_etest = !(flags & EV_TESTED); break; case NBACKGND: evalsubshell(n, flags); @@ -256,9 +260,11 @@ evaltree(union node *n, int flags) case NPIPE: evalpipe(n); + do_etest = !(flags & EV_TESTED); break; case NCMD: evalcommand(n, flags, (struct backcmd *)NULL); + do_etest = !(flags & EV_TESTED); break; default: out1fmt("Node type = %d\n", n->type); @@ -268,9 +274,7 @@ evaltree(union node *n, int flags) out: if (pendingsigs) dotrap(); - if ((flags & EV_EXIT) || (eflag && exitstatus - && !(flags & EV_TESTED) && (n->type == NCMD || - n->type == NSUBSHELL))) + if ((flags & EV_EXIT) || (eflag && exitstatus != 0 && do_etest)) exitshell(exitstatus); } -- cgit v1.1