sh: Make sure to popredir() even if a function caused an error.
This commit is contained in:
parent
c30671a949
commit
3242a81cf4
@ -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);
|
||||
|
14
tools/regression/bin/sh/builtins/command10.0
Normal file
14
tools/regression/bin/sh/builtins/command10.0
Normal file
@ -0,0 +1,14 @@
|
||||
# $FreeBSD$
|
||||
|
||||
failures=0
|
||||
|
||||
check() {
|
||||
if ! eval "[ $* ]"; then
|
||||
echo "Failed: $*"
|
||||
: $((failures += 1))
|
||||
fi
|
||||
}
|
||||
|
||||
check '"$(f() { shift x; }; { command eval f 2>/dev/null; } >/dev/null; echo hi)" = hi'
|
||||
|
||||
exit $((failures > 0))
|
Loading…
x
Reference in New Issue
Block a user