about summary refs log tree commit diff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2016-10-05 17:46:42 +0100
committerPeter Stephenson <pws@zsh.org>2016-10-05 17:46:42 +0100
commitbcb52460f3069e2e4e3b05f966a2efd40471e366 (patch)
tree8f8750eddc0f65ffb7c5912b943a39faa767f330 /Src/exec.c
parent0854ee56bc559d7fd614eb7d59b61da84a9ce51f (diff)
downloadzsh-bcb52460f3069e2e4e3b05f966a2efd40471e366.tar.gz
zsh-bcb52460f3069e2e4e3b05f966a2efd40471e366.tar.xz
zsh-bcb52460f3069e2e4e3b05f966a2efd40471e366.zip
39571: Fix ERR_EXIT bug with && and function.
"foo && bar" inside a function could cause the code outside
the function not to perform ERR_EXIT or ERR_RETURN when needed.
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 741c80e30..c0ed2c475 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1229,7 +1229,7 @@ execlist(Estate state, int dont_change_job, int exiting)
     }
     while (wc_code(code) == WC_LIST && !breaks && !retflag && !errflag) {
 	int donedebug;
-	int this_noerrexit = 0;
+	int this_noerrexit = 0, this_donetrap = 0;
 
 	ltype = WC_LIST_TYPE(code);
 	csp = cmdsp;
@@ -1353,10 +1353,10 @@ execlist(Estate state, int dont_change_job, int exiting)
 			/* We've skipped to the end of the list, not executing *
 			 * the final pipeline, so don't perform error handling *
 			 * for this sublist.                                   */
-			donetrap = 1;
+			this_donetrap = 1;
 			goto sublist_done;
 		    } else if (WC_SUBLIST_TYPE(code) == WC_SUBLIST_END) {
-			donetrap = 1;
+			this_donetrap = 1;
 			/*
 			 * Treat this in the same way as if we reached
 			 * the end of the sublist normally.
@@ -1386,10 +1386,10 @@ execlist(Estate state, int dont_change_job, int exiting)
 			/* We've skipped to the end of the list, not executing *
 			 * the final pipeline, so don't perform error handling *
 			 * for this sublist.                                   */
-			donetrap = 1;
+			this_donetrap = 1;
 			goto sublist_done;
 		    } else if (WC_SUBLIST_TYPE(code) == WC_SUBLIST_END) {
-			donetrap = 1;
+			this_donetrap = 1;
 			/*
 			 * Treat this in the same way as if we reached
 			 * the end of the sublist normally.
@@ -1439,7 +1439,7 @@ sublist_done:
 	/* Check whether we are suppressing traps/errexit *
 	 * (typically in init scripts) and if we haven't  *
 	 * already performed them for this sublist.       */
-	if (!noerrexit && !this_noerrexit && !donetrap) {
+	if (!noerrexit && !this_noerrexit && !donetrap && !this_donetrap) {
 	    if (sigtrapped[SIGZERR] && lastval) {
 		dotrap(SIGZERR);
 		donetrap = 1;