summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
authorPhilippe Altherr <philippe.altherr@gmail.com>2022-12-03 21:03:36 -0800
committerBart Schaefer <schaefer@zsh.org>2022-12-03 21:03:36 -0800
commit259f1e944b96715fda25f7ba227da05bdb7e600f (patch)
tree277afcd503da942056b9bdfbd5f0b7089d961909 /Src
parent28ac3e9fe5b68b517c477ad231966aaeed426085 (diff)
downloadzsh-259f1e944b96715fda25f7ba227da05bdb7e600f.tar.gz
zsh-259f1e944b96715fda25f7ba227da05bdb7e600f.zip
51071: fix ERR_RETURN for functions in conditional statements
Diffstat (limited to 'Src')
-rw-r--r--Src/exec.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 43df8211a..711d8f374 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1427,14 +1427,12 @@ execlist(Estate state, int dont_change_job, int exiting)
goto sublist_done;
}
while (wc_code(code) == WC_SUBLIST) {
- int isend = (WC_SUBLIST_TYPE(code) == WC_SUBLIST_END);
+ int isandor = WC_SUBLIST_TYPE(code) != WC_SUBLIST_END;
+ int isnot = WC_SUBLIST_FLAGS(code) & WC_SUBLIST_NOT;
next = state->pc + WC_SUBLIST_SKIP(code);
- if (!oldnoerrexit)
- noerrexit = isend ? 0 : NOERREXIT_EXIT | NOERREXIT_RETURN;
- if (WC_SUBLIST_FLAGS(code) & WC_SUBLIST_NOT) {
- /* suppress errexit for the commands in ! <list-of-commands> */
+ /* suppress errexit for commands before && and || and after ! */
+ if (isandor || isnot)
noerrexit = NOERREXIT_EXIT | NOERREXIT_RETURN;
- }
switch (WC_SUBLIST_TYPE(code)) {
case WC_SUBLIST_END:
/* End of sublist; just execute, ignoring status. */
@@ -1444,7 +1442,7 @@ execlist(Estate state, int dont_change_job, int exiting)
execpline(state, code, ltype, (ltype & Z_END) && exiting);
state->pc = next;
/* suppress errexit for the command "! ..." */
- if (WC_SUBLIST_FLAGS(code) & WC_SUBLIST_NOT)
+ if (isnot)
this_noerrexit = 1;
goto sublist_done;
break;