summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2011-01-05 23:17:29 +0000
committerjilles <jilles@FreeBSD.org>2011-01-05 23:17:29 +0000
commit3c4cff0f3563359fb0159ef4e85007ea7b73835f (patch)
treec31c4798788fff31d24a5179f734842633dc90a8 /bin
parent1fbda81c6445b22029b6a10f529296015c70a453 (diff)
downloadFreeBSD-src-3c4cff0f3563359fb0159ef4e85007ea7b73835f.zip
FreeBSD-src-3c4cff0f3563359fb0159ef4e85007ea7b73835f.tar.gz
sh: Do not call exitshell() from evalcommand() unless evalcommand() forked
itself. This ensures that certain traps caused by builtins are executed.
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/eval.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c
index 14dd15f..0bb5322 100644
--- a/bin/sh/eval.c
+++ b/bin/sh/eval.c
@@ -671,6 +671,7 @@ safe_builtin(int idx, int argc, char **argv)
/*
* Execute a simple command.
+ * Note: This may or may not return if (flags & EV_EXIT).
*/
static void
@@ -707,6 +708,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
arglist.lastp = &arglist.list;
varlist.lastp = &varlist.list;
varflag = 1;
+ jp = NULL;
do_clearcmdentry = 0;
oexitstatus = exitstatus;
exitstatus = 0;
@@ -965,7 +967,7 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
evalskip = 0;
skipcount = 0;
}
- if (flags & EV_EXIT)
+ if (jp)
exitshell(exitstatus);
} else if (cmdentry.cmdtype == CMDBUILTIN) {
#ifdef DEBUG
@@ -1013,13 +1015,12 @@ cmddone:
out1 = &output;
out2 = &errout;
freestdout();
+ handler = savehandler;
if (e != EXSHELLPROC) {
commandname = savecmdname;
- if (flags & EV_EXIT) {
+ if (jp)
exitshell(exitstatus);
- }
}
- handler = savehandler;
if (flags == EV_BACKCMD) {
backcmd->buf = memout.buf;
backcmd->nleft = memout.nextc - memout.buf;
OpenPOWER on IntegriCloud