about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <schaefer@zsh.org>2022-11-09 21:37:56 -0800
committerBart Schaefer <schaefer@zsh.org>2022-11-09 21:37:56 -0800
commit1ba8714a7ac665e661c1b3a716ffe2af73d1e443 (patch)
treed70e75c1cf9019781c4dcfdd809ee1fe377525f8
parent61610ea4bdc3e2de11c258017f377db3d1d6d993 (diff)
downloadzsh-1ba8714a7ac665e661c1b3a716ffe2af73d1e443.tar.gz
zsh-1ba8714a7ac665e661c1b3a716ffe2af73d1e443.tar.xz
zsh-1ba8714a7ac665e661c1b3a716ffe2af73d1e443.zip
50928: fix tests for 50897, mention behavior change in NEWS
-rw-r--r--ChangeLog3
-rw-r--r--NEWS9
-rw-r--r--Src/exec.c2
-rw-r--r--Test/C03traps.ztst17
4 files changed, 20 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index fe10e2982..d88fa4cbb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2022-11-09  Bart Schaefer  <schaefer@zsh.org>
 
+	* 50928: News, Src/exec.c, Test/C03traps.ztst: fix tests for 50897,
+	mention behavior change in NEWS
+
 	* 50922: Src/exec.c, Src/jobs.c: fix additional cases of signals
 	for current shell jobs on the right of a pipeline.  Backs out
 	part of 50874.
diff --git a/NEWS b/NEWS
index cdafd1ff5..9c28169bb 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,15 @@ CHANGES FROM PREVIOUS VERSIONS OF ZSH
 
 Note also the list of incompatibilities in the README file.
 
+Changes since 5.9
+-----------------
+
+Handling of ERR_EXIT is corrected when the final status of a structured
+command (for, select, while, repeat, if, case, or a list in braces) is
+nonzero.  To be compatible with other shells, "zsh -e" now exits in
+those circumstances, whereas previous versions did not.  This does not
+affect the handling of nonzero status within conditional statements.
+
 Changes since 5.8.1
 -------------------
 
diff --git a/Src/exec.c b/Src/exec.c
index d4e681887..eef40232e 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1442,6 +1442,8 @@ execlist(Estate state, int dont_change_job, int exiting)
 		    execsimple(state);
 		else
 		    execpline(state, code, ltype, (ltype & Z_END) && exiting);
+		if (unset(ERRRETURN))
+		    this_noerrexit = noerrexit;
 		state->pc = next;
 		goto sublist_done;
 		break;
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index f120809a7..5cc45e2de 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -713,7 +713,7 @@ F:Must be tested with a top-level script rather than source or function
     fi
   }
   fn() {
-    setopt err_return
+    setopt localoptions err_return
     fn2 || true
   }
   fn
@@ -726,8 +726,7 @@ F:Must be tested with a top-level script rather than source or function
   done
   print OK
   )
-0:ERR_EXIT not triggered by status 1 at end of for
->OK
+1:ERR_EXIT triggered by status 1 at end of for
 
   (setopt err_exit
   integer x=0
@@ -736,8 +735,7 @@ F:Must be tested with a top-level script rather than source or function
   done
   print OK
   )
-0:ERR_EXIT not triggered by status 1 at end of while
->OK
+1:ERR_EXIT triggered by status 1 at end of while
 
   (setopt err_exit
   repeat 1; do
@@ -745,8 +743,7 @@ F:Must be tested with a top-level script rather than source or function
   done
   print OK
   )
-0:ERR_EXIT not triggered by status 1 at end of repeat
->OK
+1:ERR_EXIT triggered by status 1 at end of repeat
 
   (setopt err_exit
   if true; then
@@ -754,8 +751,7 @@ F:Must be tested with a top-level script rather than source or function
   fi
   print OK
   )
-0:ERR_EXIT not triggered by status 1 at end of if
->OK
+1:ERR_EXIT triggered by status 1 at end of if
 
   (setopt err_exit
   {
@@ -763,8 +759,7 @@ F:Must be tested with a top-level script rather than source or function
   }
   print OK
   )
-0:ERR_EXIT not triggered by status 1 at end of { }
->OK
+1:ERR_EXIT triggered by status 1 at end of { }
 
   unsetopt err_exit err_return
   (setopt err_exit