summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2009-12-30 21:46:33 +0000
committerjilles <jilles@FreeBSD.org>2009-12-30 21:46:33 +0000
commit1200ca53ee6bdb87095040b33feeb3d30efbb351 (patch)
tree505629f5123d8b8368522b1237fc949fd103095f
parented965a92bc17f25c5049fbd529d10a9e94f8a3a7 (diff)
downloadFreeBSD-src-1200ca53ee6bdb87095040b33feeb3d30efbb351.zip
FreeBSD-src-1200ca53ee6bdb87095040b33feeb3d30efbb351.tar.gz
sh: Ensure funcnest is decremented if there was an error in the function.
This will be important when things like 'command eval f' will be possible. Currently, the funcnest = 0 assignment in RESET (called when returning to the top level after an error in interactive mode) is really sufficient.
-rw-r--r--bin/sh/eval.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c
index 7875f82..d5fb5ae 100644
--- a/bin/sh/eval.c
+++ b/bin/sh/eval.c
@@ -792,20 +792,20 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
unreffunc(cmdentry.u.func);
poplocalvars();
localvars = savelocalvars;
+ funcnest--;
handler = savehandler;
longjmp(handler->loc, 1);
}
handler = &jmploc;
+ funcnest++;
INTON;
for (sp = varlist.list ; sp ; sp = sp->next)
mklocal(sp->text);
- funcnest++;
exitstatus = oexitstatus;
if (flags & EV_TESTED)
evaltree(getfuncnode(cmdentry.u.func), EV_TESTED);
else
evaltree(getfuncnode(cmdentry.u.func), 0);
- funcnest--;
INTOFF;
unreffunc(cmdentry.u.func);
poplocalvars();
@@ -813,6 +813,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
freeparam(&shellparam);
shellparam = saveparam;
handler = savehandler;
+ funcnest--;
popredir();
INTON;
if (evalskip == SKIPFUNC) {
OpenPOWER on IntegriCloud