diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | Src/exec.c | 51 | ||||
-rw-r--r-- | Src/parse.c | 6 | ||||
-rw-r--r-- | Test/E01options.ztst | 12 |
4 files changed, 42 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog index 7c52b4aee..4191a9198 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2015-02-12 Barton E. Schaefer <schaefer@zsh.org> + + * 34514: Src/exec.c, Src/parse.c, Test/E01options.ztst: + Back out 34485, an alternate solution needs to be worked + out. (Tweaked to keep the unrelated hunk of the E01 test.) + 2015-02-11 Peter Stephenson <p.stephenson@samsung.com> * users/19850: Doc/Zsh/params.yo, Src/watch.c: watch variable 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: diff --git a/Src/parse.c b/Src/parse.c index ffd25de9d..0b54a904d 100644 --- a/Src/parse.c +++ b/Src/parse.c @@ -1612,7 +1612,8 @@ par_funcdef(int *cmplx) num++; zshlex(); } - *cmplx = 1; + if (num > 0) + *cmplx = 1; ecbuf[parg] = ecused - parg; /*?*/ ecbuf[parg+1] = num; } @@ -1896,7 +1897,8 @@ par_simple(int *cmplx, int nr) argc++; zshlex(); } - *cmplx = 1; + if (argc > 0) + *cmplx = 1; ecbuf[parg] = ecused - parg; /*?*/ ecbuf[parg+1] = argc; } diff --git a/Test/E01options.ztst b/Test/E01options.ztst index 32135344f..c6af80392 100644 --- a/Test/E01options.ztst +++ b/Test/E01options.ztst @@ -795,12 +795,12 @@ 1:PRINT_EXIT_VALUE option ?zsh: exit 1 - $ZTST_testdir/../Src/zsh -f <<<' - setopt printexitvalue - () { false; } - ' -1:PRINT_EXIT_VALUE option for anonymous function -?zsh: exit 1 +# $ZTST_testdir/../Src/zsh -f <<<' +# setopt printexitvalue +# () { false; } +# ' +#1:PRINT_EXIT_VALUE option for anonymous function +#?zsh: exit 1 setopt promptbang print -P ! |