Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCHv2] [bug] $SHLVL decremented for the last command of a subshell
On Tue, 30 Aug 2016 17:46:01 +0100
Stephane Chazelas <stephane.chazelas@xxxxxxxxx> wrote:
> 2016-08-30 14:04:57 +0100, Peter Stephenson:
> [...]
> > This is probably fine. I've been dithering over cases where for
> > consistency we might want to decrement SHLVL even in a subshell because
> > we're exec'ing for some other reason (so would need to do it at the last
> > minute before exiting if the exec is faked), but I suspect this is too
> > obscure to be worth special treatment.
> [...]
>
> Note that zsh is currently correctly decrementing in
>
> zsh -c '(printenv SHLVL)'
>
> Where zsh optimises out the fork(s).
>
> ksh93 seems to never decrease $SHLVL even in:
>
> $ env SHLVL=1 ksh93 -c 'exec printenv SHLVL'
> 2
When this was introduced in zsh, there was some controversy over whether
it was the right thing to do. I decided it was on the basis that the
"level" is how deep you are in the process hierarchy, rather than how
many processes have previously been executed to get where you are,
seeing as the latter isn't really visible in the current context.
But I'm not aware of any requirement specification [remember those?]
saying what the purpose of SHLVL is.
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author