summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/exec.c8
-rw-r--r--Test/C03traps.ztst40
3 files changed, 52 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d36a73639..d646732ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-07-09 Peter Stephenson <p.stephenson@samsung.com>
+
+ * 35751: Src/exec.c, Test/C03traps.ztst: fix ERR_RETURN /
+ ERR_EXIT in else branch of if.
+
2015-07-09 Mikael Magnusson <mikachu@gmail.com>
* 35745: Src/utils.c, Test/V09datetime.ztst: ztrftime: Pass
diff --git a/Src/exec.c b/Src/exec.c
index 960601f29..4eee82bf1 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1351,7 +1351,13 @@ execlist(Estate state, int dont_change_job, int exiting)
state->pc--;
sublist_done:
- noerrexit = oldnoerrexit;
+ /*
+ * See hairy code near the end of execif() for the
+ * following. "noerrexit == 2" only applies until
+ * we hit execcmd on the way down. We're now
+ * on the way back up, so don't restore it.
+ */
+ noerrexit = (oldnoerrexit == 2) ? 0 : oldnoerrexit;
if (sigtrapped[SIGDEBUG] && !isset(DEBUGBEFORECMD) && !donedebug) {
/*
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index 757f75ca4..4e2338825 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -399,6 +399,46 @@
)
1:ERREXIT in loop with simple commands
+ fn() {
+ emulate -L zsh
+ setopt errreturn
+ if false; then
+ false
+ print No.
+ else
+ print Oh, yes
+ fi
+ }
+ fn
+0:ERRRETURN not triggered in if condition
+>Oh, yes
+
+ fn() {
+ emulate -L zsh
+ setopt errreturn
+ if true; then
+ false
+ print No.
+ else
+ print No, no.
+ fi
+ }
+ fn
+1:ERRRETURN in "if"
+
+ fn() {
+ emulate -L zsh
+ setopt errreturn
+ if false; then
+ print No.
+ else
+ false
+ print No, no.
+ fi
+ }
+ fn
+1:ERRRETURN in "else" branch (regression test)
+
%clean
rm -f TRAPEXIT