Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCHv2] [bug] $SHLVL decremented for the last command of a subshell
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
bash only optimises out the fork in the
bash -c 'single command'
case and gets it wrong:
$ env SHLVL=1 bash -c 'printenv SHLVL'
2
$ env SHLVL=1 bash -c 'exec printenv SHLVL'
1
tcsh doesn't opimise out any fork AFAICT.
Other shells don't seem to support $SHLVL.
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author