diff options
author | jilles <jilles@FreeBSD.org> | 2010-03-06 17:31:09 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2010-03-06 17:31:09 +0000 |
commit | 3242a81cf43fb6016f65673c693e101d491d0e6a (patch) | |
tree | 19870d344864f5031127af5c39f2a3ff00900053 /bin | |
parent | c30671a949eb9683bebf9a37cc4e35a46fde00d9 (diff) | |
download | FreeBSD-src-3242a81cf43fb6016f65673c693e101d491d0e6a.zip FreeBSD-src-3242a81cf43fb6016f65673c693e101d491d0e6a.tar.gz |
sh: Make sure to popredir() even if a function caused an error.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/sh/eval.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c index b1de306..cdd6386 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -813,7 +813,6 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd) #ifdef DEBUG trputs("Shell function: "); trargs(argv); #endif - redirect(cmd->ncmd.redirect, REDIR_PUSH); saveparam = shellparam; shellparam.malloc = 0; shellparam.reset = 1; @@ -831,6 +830,8 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd) else { freeparam(&shellparam); shellparam = saveparam; + if (exception == EXERROR || exception == EXEXEC) + popredir(); } unreffunc(cmdentry.u.func); poplocalvars(); @@ -841,6 +842,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd) } handler = &jmploc; funcnest++; + redirect(cmd->ncmd.redirect, REDIR_PUSH); INTON; for (sp = varlist.list ; sp ; sp = sp->next) mklocal(sp->text); |