From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22384 invoked from network); 5 Sep 2008 19:50:45 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 5 Sep 2008 19:50:45 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 63242 invoked from network); 5 Sep 2008 19:50:37 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 5 Sep 2008 19:50:37 -0000 Received: (qmail 6745 invoked by alias); 5 Sep 2008 19:50:26 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25625 Received: (qmail 6718 invoked from network); 5 Sep 2008 19:50:22 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 5 Sep 2008 19:50:22 -0000 Received: from mx.spodhuis.org (unknown [193.202.115.177]) by bifrost.dotsrc.org (Postfix) with ESMTPS id E91D2809A19E for ; Fri, 5 Sep 2008 21:49:47 +0200 (CEST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=d200807; d=spodhuis.org; h=Received:Date:From:To:Cc:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; b=SsSyr6IP2+P8xomxzZoZ/fMCG5MdyFOPLhP9DvsezhXgjoW1qh+G0XGVTwDbypAh78kjYu4v4YlPt3Kw7dRwI4Em4FD3UWe+boyORZCnpbfSHwRMDmPIupBFVLen8f9CySHQScGtSyA9e0fNuEW17VGR1BjmLGIj3T8XZsS+s6g=; Received: by smtp.spodhuis.org with local id 1KbhIv-0006mr-3t; Fri, 05 Sep 2008 19:49:13 +0000 Date: Fri, 5 Sep 2008 12:49:13 -0700 From: Phil Pennock To: Rocky Bernstein Cc: Zsh hackers list Subject: Re: Request: a way to get the subshell level nesting Message-ID: <20080905194912.GA80349@redoubt.spodhuis.org> Mail-Followup-To: Rocky Bernstein , Zsh hackers list References: <6cd6de210809050711h4811efei413630fb514333ae@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6cd6de210809050711h4811efei413630fb514333ae@mail.gmail.com> X-Virus-Scanned: ClamAV 0.92.1/8168/Fri Sep 5 20:38:03 2008 on bifrost X-Virus-Status: Clean 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