diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Src/exec.c | 9 | ||||
-rw-r--r-- | Test/C03traps.ztst | 27 |
3 files changed, 37 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog index ea3eed8a4..318c8df33 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2016-10-05 Peter Stephenson <p.stephenson@samsung.com> + * 39568: Src/exec.c, Test/C03traps.ztst: "! <complex-command>" + should suppress ERR_EXIT inside the complex command. + * 39566: README, Doc/Zsh/exec.yo, Src/exec.c, Test/C04funcdef.ztst: change the behaviour of command_not_found_handler to make it easier to handle a non-zero diff --git a/Src/exec.c b/Src/exec.c index f248ca288..741c80e30 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -1317,8 +1317,13 @@ execlist(Estate state, int dont_change_job, int exiting) next = state->pc + WC_SUBLIST_SKIP(code); if (!oldnoerrexit) noerrexit = !isend; - if ((WC_SUBLIST_FLAGS(code) & WC_SUBLIST_NOT) && isend) - this_noerrexit = 1; + if (WC_SUBLIST_FLAGS(code) & WC_SUBLIST_NOT) { + /* suppress errexit for "! this_command" */ + if (isend) + this_noerrexit = 1; + /* suppress errexit for ! <list-of-shell-commands> */ + noerrexit = 1; + } switch (WC_SUBLIST_TYPE(code)) { case WC_SUBLIST_END: /* End of sublist; just execute, ignoring status. */ diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst index 3a65b2876..0faec02e9 100644 --- a/Test/C03traps.ztst +++ b/Test/C03traps.ztst @@ -556,6 +556,33 @@ F:Must be tested with a top-level script rather than source or function 1:ERRETURN with "!" and a following false >before + fn() { + emulate -L zsh + setopt errreturn + print before + ! if true; then + false + fi + print after + } + fn +0:ERRETURN with "!" suppressed inside complex structure +>before +>after + + fn() { + emulate -L zsh + setopt errreturn + print before + if true; then + false + fi + print after + } + fn +1:ERRETURN with no "!" suppression (control case) +>before + %clean rm -f TRAPEXIT |