zsh-workers
 help / color / mirror / code / Atom feed
From: Phil Pennock <zsh-workers+phil.pennock@spodhuis.org>
To: Rocky Bernstein <rocky.bernstein@gmail.com>
Cc: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: Request: a way to get the subshell level nesting
Date: Fri, 5 Sep 2008 12:49:13 -0700	[thread overview]
Message-ID: <20080905194912.GA80349@redoubt.spodhuis.org> (raw)
In-Reply-To: <6cd6de210809050711h4811efei413630fb514333ae@mail.gmail.com>

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


  reply	other threads:[~2008-09-05 19:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-05 14:11 Rocky Bernstein
2008-09-05 19:49 ` Phil Pennock [this message]
2008-09-05 19:55   ` Rocky Bernstein
2008-09-05 20:45 ` Peter Stephenson
2008-09-05 21:36   ` Rocky Bernstein
2008-09-06 21:23     ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080905194912.GA80349@redoubt.spodhuis.org \
    --to=zsh-workers+phil.pennock@spodhuis.org \
    --cc=rocky.bernstein@gmail.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).