about summary refs log tree commit diff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorStephane Chazelas <stephane.chazelas@gmail.com>2016-08-30 13:44:26 +0100
committerPeter Stephenson <pws@zsh.org>2016-08-31 10:21:00 +0100
commit8ce98c75f5330eecfa474e342146b8d057abcefc (patch)
treee6a98cc00046134c2e30c214a8a5282fe193a044 /Src/exec.c
parent70166178bdc7ea149eb1cd29bcdb549a392c46dd (diff)
downloadzsh-8ce98c75f5330eecfa474e342146b8d057abcefc.tar.gz
zsh-8ce98c75f5330eecfa474e342146b8d057abcefc.tar.xz
zsh-8ce98c75f5330eecfa474e342146b8d057abcefc.zip
39125: More care needed decrementing SHLVL on exec.
Not needed in subshell.
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 9b24d388e..2e251b939 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3694,12 +3694,15 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		restore_params(restorelist, removelist);
 
 	} else {
-	    if (!forked)
-		setiparam("SHLVL", --shlvl);
-	    if (do_exec) {
+	    if (!subsh) {
+	        /* for either implicit or explicit "exec", decrease $SHLVL
+		 * as we're now done as a shell */
+		if (!forked)
+		    setiparam("SHLVL", --shlvl);
+
 		/* If we are exec'ing a command, and we are not *
 		 * in a subshell, then save the history file.   */
-		if (!subsh && isset(RCS) && interact && !nohistsave)
+		if (do_exec && isset(RCS) && interact && !nohistsave)
 		    savehistfile(NULL, 1, HFILE_USE_OPTIONS);
 	    }
 	    if (type == WC_SIMPLE || type == WC_TYPESET) {