diff options
author | Jilles Tjoelker <jilles@FreeBSD.org> | 2009-11-22 14:04:20 +0000 |
---|---|---|
committer | Jilles Tjoelker <jilles@FreeBSD.org> | 2009-11-22 14:04:20 +0000 |
commit | eaa3489312d377f27befcc40ebfc8f9e0460c0b9 (patch) | |
tree | 0ba1f228ffeefae0838e106fccaf6a76f2040cce /bin/sh/eval.c | |
parent | 301f81f0fbdbfb17ba5394898821af4f0b60b1b5 (diff) | |
download | src-eaa3489312d377f27befcc40ebfc8f9e0460c0b9.tar.gz src-eaa3489312d377f27befcc40ebfc8f9e0460c0b9.zip |
sh: Ensure the same command input file is on top after executing a builtin.
This avoids weirdness when 'fc -e vi' or the like is done and there is a
syntax error in the file. Formerly an interactive shell tried to execute
stuff after the syntax error and exited.
This should also avoid similar issues with 'command eval' and 'command .'
when 'command' is implemented properly as in NetBSD sh.
Special builtins did not have this problem since errors in them cause the
shell to exit or to reset various state such as the current command input
file.
Notes
Notes:
svn path=/head/; revision=199647
Diffstat (limited to 'bin/sh/eval.c')
-rw-r--r-- | bin/sh/eval.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c index 5ba244d76e41..81de2d79e0f5 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -593,6 +593,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd) char *savecmdname; struct shparam saveparam; struct localvar *savelocalvars; + struct parsefile *savetopfile; volatile int e; char *lastarg; int realstatus; @@ -833,6 +834,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd) mode |= REDIR_BACKQ; } savecmdname = commandname; + savetopfile = getcurrentfile(); cmdenviron = varlist.list; e = -1; savehandler = handler; @@ -867,6 +869,7 @@ cmddone: if ((e != EXERROR && e != EXEXEC) || cmdentry.special) exraise(e); + popfilesupto(savetopfile); FORCEINTON; } if (cmdentry.u.index != EXECCMD) |