summaryrefslogtreecommitdiff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2015-02-12 09:27:53 -0800
committerBarton E. Schaefer <schaefer@zsh.org>2015-02-12 09:27:53 -0800
commit7398fea05980df98a29eac6f504397ea0cb3be7a (patch)
tree6dd8a18a6cee632fa966946c42983b14a0375c7e /Src/exec.c
parent638bccb1c5e85da44f0dd551cc97bd522e633b4b (diff)
downloadzsh-7398fea05980df98a29eac6f504397ea0cb3be7a.tar.gz
zsh-7398fea05980df98a29eac6f504397ea0cb3be7a.zip
34514: Back out 34485, an alternate solution needs to be worked out.
(Tweaked to keep the unrelated hunk of the E01 test.)
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 9bbcf4979..3b0e936b4 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2427,7 +2427,6 @@ execcmd(Estate state, int input, int output, int how, int last1)
wordcode code;
Wordcode beg = state->pc, varspc;
FILE *oxtrerr = xtrerr, *newxtrerr = NULL;
- LinkList restorelist = 0, removelist = 0;
doneps4 = 0;
redir = (wc_code(*state->pc) == WC_REDIR ? ecgetredirs(state) : NULL);
@@ -3360,9 +3359,9 @@ execcmd(Estate state, int input, int output, int how, int last1)
zcontext_restore();
} else
redir_prog = NULL;
-
+
lastval = execfuncdef(state, redir_prog);
- }
+ }
else if (type >= WC_CURSH) {
if (last1 == 1)
do_exec = 1;
@@ -3375,6 +3374,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
} else
lastval = (execfuncs[type - WC_CURSH])(state, do_exec);
} else if (is_builtin || is_shfunc) {
+ LinkList restorelist = 0, removelist = 0;
/* builtin or shell function */
if (!forked && ((cflags & BINF_COMMAND) ||
@@ -3424,6 +3424,29 @@ execcmd(Estate state, int input, int output, int how, int last1)
} else
clearerr(stdout);
}
+ if (isset(PRINTEXITVALUE) && isset(SHINSTDIN) &&
+ lastval && !subsh) {
+#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
+ fprintf(stderr, "zsh: exit %lld\n", lastval);
+#else
+ fprintf(stderr, "zsh: exit %ld\n", (long)lastval);
+#endif
+ fflush(stderr);
+ }
+
+ if (do_exec) {
+ if (subsh)
+ _exit(lastval);
+
+ /* If we are exec'ing a command, and we are not in a subshell, *
+ * then check if we should save the history file. */
+ if (isset(RCS) && interact && !nohistsave)
+ savehistfile(NULL, 1, HFILE_USE_OPTIONS);
+ exit(lastval);
+ }
+ if (restorelist)
+ restore_params(restorelist, removelist);
+
} else {
if (!forked)
setiparam("SHLVL", --shlvl);
@@ -3473,28 +3496,6 @@ execcmd(Estate state, int input, int output, int how, int last1)
execlist(state, 0, 1);
}
}
- if (isset(PRINTEXITVALUE) && isset(SHINSTDIN) &&
- lastval && !subsh) {
-#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
- fprintf(stderr, "zsh: exit %lld\n", lastval);
-#else
- fprintf(stderr, "zsh: exit %ld\n", (long)lastval);
-#endif
- fflush(stderr);
- }
-
- if (do_exec) {
- if (subsh)
- _exit(lastval);
-
- /* If we are exec'ing a command, and we are not in a subshell, *
- * then check if we should save the history file. */
- if (isset(RCS) && interact && !nohistsave)
- savehistfile(NULL, 1, HFILE_USE_OPTIONS);
- exit(lastval);
- }
- if (restorelist)
- restore_params(restorelist, removelist);
}
err: