about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/loop.c2
-rw-r--r--Test/C03traps.ztst9
3 files changed, 15 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d4dbb2e12..663b3e88f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2020-02-02  Peter Stephenson  <p.w.stephenson@ntlworld.com>
+
+	* 45373: Src/loop.c, Test/C03traps.ztst: ERR_EXIT failed on
+	command substitution in else branch.
+
 2020-02-02  Daniel Shahaf  <danielsh@apache.org>
 
 	* 45372: Etc/BUGS: Record a symlink loop bug involving :P
diff --git a/Src/loop.c b/Src/loop.c
index 538afb8dc..01abc6cc9 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -570,7 +570,7 @@ execif(Estate state, int do_exec)
 
     if (run) {
 	/* we need to ignore lastval until we reach execcmd() */
-	if (olderrexit)
+	if (olderrexit || run == 2)
 	    noerrexit = olderrexit;
 	else if (lastval)
 	    noerrexit |= NOERREXIT_EXIT | NOERREXIT_RETURN | NOERREXIT_UNTIL_EXEC;
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index e661aabd5..6f84e5db2 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -500,6 +500,15 @@
 >Succeed 2
 >Succeed 3
 
+  (set -e
+   if false; then
+   else
+       a=$(false)
+       print This should not appear
+   fi
+  )
+1:ERREXIT is triggered in an else block after a cmd subst returning false
+
   fn() {
     emulate -L zsh
     setopt errreturn