diff options
author | stefanf <stefanf@FreeBSD.org> | 2005-09-10 08:25:28 +0000 |
---|---|---|
committer | stefanf <stefanf@FreeBSD.org> | 2005-09-10 08:25:28 +0000 |
commit | c39c1e0d62641cb10c7b66e507332eed6e8a4c4f (patch) | |
tree | 76e64b8e41106f603407c4d3d4e85bd4c27b7cc1 /bin | |
parent | 2485a74343577b25f8e4fdb207039372ba58d9fa (diff) | |
download | FreeBSD-src-c39c1e0d62641cb10c7b66e507332eed6e8a4c4f.zip FreeBSD-src-c39c1e0d62641cb10c7b66e507332eed6e8a4c4f.tar.gz |
Pass the EV_TESTED flag to evalloop() and evalfor(). This fixes unwanted
termination with set -e if a command fails in a loop body inside a function
with an explicitely tested exit status, eg
f() {
for i in 1 2 3; do
false
done
}
f || true
Briefly reviewed by: cracauer
Diffstat (limited to 'bin')
-rw-r--r-- | bin/sh/eval.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c index ada2a78..ddf2275 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -90,8 +90,8 @@ int exitstatus; /* exit status of last command */ int oexitstatus; /* saved exit status */ -STATIC void evalloop(union node *); -STATIC void evalfor(union node *); +STATIC void evalloop(union node *, int); +STATIC void evalfor(union node *, int); STATIC void evalcase(union node *, int); STATIC void evalsubshell(union node *, int); STATIC void expredir(union node *); @@ -241,10 +241,10 @@ evaltree(union node *n, int flags) } case NWHILE: case NUNTIL: - evalloop(n); + evalloop(n, flags & ~EV_EXIT); break; case NFOR: - evalfor(n); + evalfor(n, flags & ~EV_EXIT); break; case NCASE: evalcase(n, flags); @@ -280,7 +280,7 @@ out: STATIC void -evalloop(union node *n) +evalloop(union node *n, int flags) { int status; @@ -304,7 +304,7 @@ skipping: if (evalskip == SKIPCONT && --skipcount <= 0) { if (exitstatus == 0) break; } - evaltree(n->nbinary.ch2, 0); + evaltree(n->nbinary.ch2, flags); status = exitstatus; if (evalskip) goto skipping; @@ -316,7 +316,7 @@ skipping: if (evalskip == SKIPCONT && --skipcount <= 0) { STATIC void -evalfor(union node *n) +evalfor(union node *n, int flags) { struct arglist arglist; union node *argp; @@ -337,7 +337,7 @@ evalfor(union node *n) loopnest++; for (sp = arglist.list ; sp ; sp = sp->next) { setvar(n->nfor.var, sp->text, 0); - evaltree(n->nfor.body, 0); + evaltree(n->nfor.body, flags); if (evalskip) { if (evalskip == SKIPCONT && --skipcount <= 0) { evalskip = 0; |