Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] [bug] $SHLVL decremented for the last command of a subshell
- X-seq: zsh-workers 39119
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: [PATCH] [bug] $SHLVL decremented for the last command of a subshell
- Date: Mon, 29 Aug 2016 16:51:56 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=S+CUWjKFof6bvBeaWXjGyQjgLiGjnWLwuiGoijHAYdI=; b=Dy0nkfdpDK6BGhjpbz5zZTKhb7QUc+tg6aq5T5W/2KrDd9Tx0c6nNOMt3Qwt2ckEiU J+UpnZN9j3+doGrWEdbnD4MhMBno0bZd7fpsSaGx3PsOVGgrywH8hJAjMfYgCjAB2Dmq dE6RjEjxBly4knCjdlld4X4VqvHXHu9PhM4VdXKLyGdAkCaBfo/JsR3VenaRnyMIISVN awdjRYV1ia7v5LRAmi6io5pXhc4lVond27tKjxDVDty0yZBBycJrHra8rtGlErBtMxkd OQUWCvsjQsd/e8HwxPtFRg10NNtyJr7bqoSYKWdfnqtaQEJ0UlCXxmsUc0w48RcEbJXQ uqOQ==
- In-reply-to: <20160822061723.GA7308@chaz.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20160822061723.GA7308@chaz.gmail.com>
2016-08-22 07:17:23 +0100, Stephane Chazelas:
> (from https://unix.stackexchange.com/questions/304917/detect-when-zsh-is-running-within-the-subshell-of-another-shell)
>
> $ printenv SHLVL
> 1
> $ (printenv SHLVL)
> 0
> $ (printenv SHLVL;:)
> 1
> $ (:;printenv SHLVL)
> 0
>
>
> http://www.zsh.org/mla/workers/1999/msg02472.html
> sounds like a potential culprit.
[...]
I think the change below should be enough (also condensed the 2
"if"s below (unrelated)):
diff --git a/Src/exec.c b/Src/exec.c
index 9b24d38..54ececc 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3694,14 +3694,12 @@ execcmd(Estate state, int input, int output, int how, int last1)
restore_params(restorelist, removelist);
} else {
- if (!forked)
+ if (!forked && !subsh)
setiparam("SHLVL", --shlvl);
- if (do_exec) {
+ if (do_exec && !subsh && isset(RCS) && interact && !nohistsave)
/* 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)
- savehistfile(NULL, 1, HFILE_USE_OPTIONS);
- }
+ savehistfile(NULL, 1, HFILE_USE_OPTIONS);
if (type == WC_SIMPLE || type == WC_TYPESET) {
if (varspc) {
int addflags = ADDVAR_EXPORT|ADDVAR_RESTRICT;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author