From 8ce98c75f5330eecfa474e342146b8d057abcefc Mon Sep 17 00:00:00 2001 From: Stephane Chazelas Date: Tue, 30 Aug 2016 13:44:26 +0100 Subject: 39125: More care needed decrementing SHLVL on exec. Not needed in subshell. --- Src/exec.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Src/exec.c') 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) { -- cgit 1.4.1