summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorstefanf <stefanf@FreeBSD.org>2005-09-10 07:41:36 +0000
committerstefanf <stefanf@FreeBSD.org>2005-09-10 07:41:36 +0000
commitea5e582b96e1d9ae20a4dfb62eb1f7235c71694d (patch)
tree94c8858e6a26daffdbc52d21607d2ed9e9325dbb /bin
parent025772468593229799c3f46e3f872a1c52c2fc3d (diff)
downloadFreeBSD-src-ea5e582b96e1d9ae20a4dfb62eb1f7235c71694d.zip
FreeBSD-src-ea5e582b96e1d9ae20a4dfb62eb1f7235c71694d.tar.gz
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
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/eval.c10
1 files changed, 7 insertions, 3 deletions
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);
}
OpenPOWER on IntegriCloud