about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhilippe Altherr <philippe.altherr@gmail.com>2022-12-03 21:35:51 -0800
committerBart Schaefer <schaefer@zsh.org>2022-12-03 21:35:51 -0800
commitab9c579ef9a1ad6482267719f5d031f6a5dbf24e (patch)
treeca8213bf78fc1673c3951ef70bb53e91706c9d36
parentf253ea6b9d14901e24fa6a376936effad9e6547b (diff)
downloadzsh-ab9c579ef9a1ad6482267719f5d031f6a5dbf24e.tar.gz
zsh-ab9c579ef9a1ad6482267719f5d031f6a5dbf24e.tar.xz
zsh-ab9c579ef9a1ad6482267719f5d031f6a5dbf24e.zip
51098: remove unreachable NOERREXIT_UNTIL_EXEC code and effects
-rw-r--r--ChangeLog3
-rw-r--r--Src/exec.c13
-rw-r--r--Src/loop.c15
-rw-r--r--Src/zsh.h2
4 files changed, 7 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 2355b4fa1..91c8e69d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2022-12-03  Bart Schaefer  <schaefer@zsh.org>
 
+	* Philippe Altherr: 51098: Src/exec.c, Src/loop.c, Src/zsh.h:
+	remove unreachable NOERREXIT_UNTIL_EXEC code and effects
+
 	* Philippe Altherr: 51076: Src/exec.c, Test/C03traps.ztst: fix
 	ERR_EXIT when used with "eval" or "source"; documentary comments
 
diff --git a/Src/exec.c b/Src/exec.c
index 8ff6489ec..1dd569019 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1559,14 +1559,7 @@ execlist(Estate state, int dont_change_job, int exiting)
 	state->pc--;
 sublist_done:
 
-	/*
-	 * See hairy code near the end of execif() for the
-	 * following.  "noerrexit " only applies until
-	 * we hit execcmd on the way down.  We're now
-	 * on the way back up, so don't restore it.
-	 */
-	if (!(oldnoerrexit & NOERREXIT_UNTIL_EXEC))
-	    noerrexit = oldnoerrexit;
+	noerrexit = oldnoerrexit;
 
 	if (sigtrapped[SIGDEBUG] && !isset(DEBUGBEFORECMD) && !donedebug) {
 	    /*
@@ -3246,10 +3239,6 @@ execcmd_exec(Estate state, Execcmd_params eparams,
     } else
 	preargs = NULL;
 
-    /* if we get this far, it is OK to pay attention to lastval again */
-    if (noerrexit & NOERREXIT_UNTIL_EXEC)
-	noerrexit = 0;
-
     /* Do prefork substitutions.
      *
      * Decide if we need "magic" handling of ~'s etc. in
diff --git a/Src/loop.c b/Src/loop.c
index 7c3e04b8a..61543ed73 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -569,23 +569,14 @@ execif(Estate state, int do_exec)
 	s = 1;
 	state->pc = next;
     }
+    noerrexit = olderrexit;
 
     if (run) {
-	/* we need to ignore lastval until we reach execcmd() */
-	if (olderrexit || run == 2)
-	    noerrexit = olderrexit;
-	else if (lastval)
-	    noerrexit |= NOERREXIT_EXIT | NOERREXIT_RETURN | NOERREXIT_UNTIL_EXEC;
-	else
-	    noerrexit &= ~ (NOERREXIT_EXIT | NOERREXIT_RETURN);
 	cmdpush(run == 2 ? CS_ELSE : (s ? CS_ELIFTHEN : CS_IFTHEN));
 	execlist(state, 1, do_exec);
 	cmdpop();
-    } else {
-	noerrexit = olderrexit;
-	if (!retflag && !errflag)
-	    lastval = 0;
-    }
+    } else if (!retflag && !errflag)
+	lastval = 0;
     state->pc = end;
     this_noerrexit = 1;
 
diff --git a/Src/zsh.h b/Src/zsh.h
index 40f9ea537..703231ca2 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -2220,8 +2220,6 @@ enum noerrexit_bits {
     NOERREXIT_EXIT = 1,
     /* Suppress ERR_RETURN: per function call */
     NOERREXIT_RETURN = 2,
-    /* NOERREXIT only needed on way down */
-    NOERREXIT_UNTIL_EXEC = 4,
     /* Force exit on SIGINT */
     NOERREXIT_SIGNAL = 8
 };