summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2016-12-05 11:21:01 +0000
committerPeter Stephenson <pws@zsh.org>2016-12-05 11:21:01 +0000
commitc03228f9ed28dfaa9ded49eabb93c04def5ac547 (patch)
tree7ea3ee905bf9531dce1e4e46b206ac9eb438d566 /Src
parentf71de84f1d9f7c2d63226a2e5534fc12d05ec716 (diff)
downloadzsh-c03228f9ed28dfaa9ded49eabb93c04def5ac547.tar.gz
zsh-c03228f9ed28dfaa9ded49eabb93c04def5ac547.tar.xz
zsh-c03228f9ed28dfaa9ded49eabb93c04def5ac547.zip
Extra case for ERR_RETURN and ERR_EXIT.
Don't trigger just because status is non-zero at end of
complex shell construct as this may be a case we've already
suppressed.
Diffstat (limited to 'Src')
-rw-r--r--Src/exec.c10
-rw-r--r--Src/loop.c6
-rw-r--r--Src/zsh.h1
3 files changed, 16 insertions, 1 deletions
diff --git a/Src/exec.c b/Src/exec.c
index f544a33e7..6e197ddf2 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -46,6 +46,11 @@ enum {
 /**/
 int noerrexit;
 
+/* used to suppress ERREXIT for one occurrence */
+
+/**/
+int this_noerrexit;
+
 /*
  * noerrs = 1: suppress error messages
  * noerrs = 2: don't set errflag on parse error, either
@@ -1238,7 +1243,8 @@ execlist(Estate state, int dont_change_job, int exiting)
     }
     while (wc_code(code) == WC_LIST && !breaks && !retflag && !errflag) {
 	int donedebug;
-	int this_noerrexit = 0, this_donetrap = 0;
+	int this_donetrap = 0;
+	this_noerrexit = 0;
 
 	ltype = WC_LIST_TYPE(code);
 	csp = cmdsp;
@@ -5813,6 +5819,7 @@ execsave(void)
     es->trapisfunc = trapisfunc;
     es->traplocallevel = traplocallevel;
     es->noerrs = noerrs;
+    es->this_noerrexit = this_noerrexit;
     es->underscore = ztrdup(zunderscore);
     es->next = exstack;
     exstack = es;
@@ -5847,6 +5854,7 @@ execrestore(void)
     trapisfunc = en->trapisfunc;
     traplocallevel = en->traplocallevel;
     noerrs = en->noerrs;
+    this_noerrexit = en->this_noerrexit;
     setunderscore(en->underscore);
     zsfree(en->underscore);
     free(en);
diff --git a/Src/loop.c b/Src/loop.c
index 367c0df5c..ae87b2f5f 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -208,6 +208,7 @@ execfor(Estate state, int do_exec)
     loops--;
     simple_pline = old_simple_pline;
     state->pc = end;
+    this_noerrexit = 1;
     return lastval;
 }
 
@@ -335,6 +336,7 @@ execselect(Estate state, UNUSED(int do_exec))
     loops--;
     simple_pline = old_simple_pline;
     state->pc = end;
+    this_noerrexit = 1;
     return lastval;
 }
 
@@ -472,6 +474,7 @@ execwhile(Estate state, UNUSED(int do_exec))
     popheap();
     loops--;
     state->pc = end;
+    this_noerrexit = 1;
     return lastval;
 }
 
@@ -523,6 +526,7 @@ execrepeat(Estate state, UNUSED(int do_exec))
     loops--;
     simple_pline = old_simple_pline;
     state->pc = end;
+    this_noerrexit = 1;
     return lastval;
 }
 
@@ -573,6 +577,7 @@ execif(Estate state, int do_exec)
 	    lastval = 0;
     }
     state->pc = end;
+    this_noerrexit = 1;
 
     return lastval;
 }
@@ -682,6 +687,7 @@ execcase(Estate state, int do_exec)
 
     if (!anypatok)
 	lastval = 0;
+    this_noerrexit = 1;
 
     return lastval;
 }
diff --git a/Src/zsh.h b/Src/zsh.h
index dae2b2459..f2c030004 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1070,6 +1070,7 @@ struct execstack {
     int trapisfunc;
     int traplocallevel;
     int noerrs;
+    int this_noerrexit;
     char *underscore;
 };