sh: Make sure to popredir() even if a special builtin caused an error.

This commit is contained in:
Jilles Tjoelker 2010-03-06 17:09:22 +00:00
parent c848bc18e8
commit 544754df6f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=204801
2 changed files with 17 additions and 2 deletions

View File

@ -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);

View 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))