aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorStefan Farfeleder <stefanf@FreeBSD.org>2005-09-10 08:25:28 +0000
committerStefan Farfeleder <stefanf@FreeBSD.org>2005-09-10 08:25:28 +0000
commit4ee9cb0e264d56ccc0cc16dfc816111da0509f45 (patch)
tree76e64b8e41106f603407c4d3d4e85bd4c27b7cc1 /bin
parent2340828b1ee78093426c38a8ba76a0efa02d15b0 (diff)
downloadsrc-4ee9cb0e264d56ccc0cc16dfc816111da0509f45.tar.gz
src-4ee9cb0e264d56ccc0cc16dfc816111da0509f45.zip
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
Notes
Notes: svn path=/head/; revision=149933
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/eval.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c
index ada2a788e2e0..ddf227526ad9 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;