Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Request: a way to get the subshell level nesting



On 2008-09-05 at 10:11 -0400, Rocky Bernstein wrote:
> It would be great if there were a way to get the subshell level nesting. ksh
> uses .sh.level and bash BASH_SUBSHELL.

I don't think zsh has that directly as a variable, but it does have %_
for prompt substitution, producing on stdout a list of words identifying
the nested parser states.  It's output text, not a data structure
internal to the shell (so not an array).

zsh% for i in 1; do if [[ x == x ]]; then print -P %_ ; fi; done 
for then
zsh%

Of course, capturing that in $(...) will add a cmdsubst to the end.

-Phil



Messages sorted by: Reverse Date, Date, Thread, Author