sh: Make sure to popredir() even if a special builtin caused an error.
This commit is contained in:
parent
c848bc18e8
commit
544754df6f
@ -914,6 +914,9 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
|
||||
backcmd->nleft = memout.nextc - memout.buf;
|
||||
memout.buf = NULL;
|
||||
}
|
||||
if (cmdentry.u.index != EXECCMD &&
|
||||
(e == -1 || e == EXERROR || e == EXEXEC))
|
||||
popredir();
|
||||
if (e != -1) {
|
||||
if ((e != EXERROR && e != EXEXEC)
|
||||
|| cmdentry.special)
|
||||
@ -922,8 +925,6 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
|
||||
if (flags != EV_BACKCMD)
|
||||
FORCEINTON;
|
||||
}
|
||||
if (cmdentry.u.index != EXECCMD)
|
||||
popredir();
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
trputs("normal command: "); trargs(argv);
|
||||
|
14
tools/regression/bin/sh/builtins/command9.0
Normal file
14
tools/regression/bin/sh/builtins/command9.0
Normal file
@ -0,0 +1,14 @@
|
||||
# $FreeBSD$
|
||||
|
||||
failures=0
|
||||
|
||||
check() {
|
||||
if ! eval "[ $* ]"; then
|
||||
echo "Failed: $*"
|
||||
: $((failures += 1))
|
||||
fi
|
||||
}
|
||||
|
||||
check '"$({ command eval shift x 2>/dev/null; } >/dev/null; echo hi)" = hi'
|
||||
|
||||
exit $((failures > 0))
|
Loading…
Reference in New Issue
Block a user