diff options
-rw-r--r-- | bin/sh/eval.c | 4 | ||||
-rw-r--r-- | tools/regression/bin/sh/builtins/command10.0 | 14 |
2 files changed, 17 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); diff --git a/tools/regression/bin/sh/builtins/command10.0 b/tools/regression/bin/sh/builtins/command10.0 new file mode 100644 index 0000000..2c1adf1 --- /dev/null +++ b/tools/regression/bin/sh/builtins/command10.0 @@ -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)) |