bash - Zsh weirdness regarding $SHLVL -
can explain next behaviour, please?
$ echo $shlvl 1 $ zsh -c 'echo $shlvl' 2 $ zsh -c '(echo $shlvl)' 1 i don't understand lastly result. zsh reset $shlvl () subshells? bash result different:
$ echo $shlvl 1 $ bash -c 'echo $shlvl' 2 $ bash -c '(echo $shlvl)' 2 which, @ least, seems more logical. in case, expecting 3 lastly result when tested this. why no shell gives result? misunderstanding $shlvl?
in bash variable shlvl not incremented subshells, see abs guide. nested subshells see bash_subshell.
in zsh doc says shlvl counts number of shells, see here, , that, surprise, zsh_subshell counts nested subshells, see here.
to me, decrementing effect of shlvl in zsh subshell bug; possibility shlvl , zsh_subshell might added (an undocumented feature?).
$ zsh -c 'print $shlvl $zsh_subshell ; (print $shlvl $zsh_subshell)' 2 0 1 1 bash shell zsh
No comments:
Post a Comment