From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11403 invoked by alias); 31 Aug 2016 17:29:02 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 39142 Received: (qmail 16010 invoked from network); 31 Aug 2016 17:28:57 -0000 X-Qmail-Scanner-Diagnostics: from mail-wm0-f52.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(74.125.82.52):SA:0(0.0/5.0):. Processed in 1.332903 secs); 31 Aug 2016 17:28:57 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM,SPF_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: stephane.chazelas@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 74.125.82.52 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=5tRnzXYKTkS2M0kMpjkPwqep+DThbcjgh/IT/l957vY=; b=RJXr2iyB1XqU+C3I/+Z5SAXplshuZQnQeNJmLLrFi336kATJ302ymetjB2FEwhbjFG WOiBx8poTWofonVlB6r3hlz3+k9H/Hh6R7d1/IguyIoiTRhWk+s2eeSqiUeZAM6He+Z2 f2ITkaOzXtVY6+PJtALbuyMxmFr7fapQjekhZE4WMOnsr4XsWvARljgaJNabsdh9BWxA kJQuWtQIHfSEeITcuFqRWYkvd/BvfnbBjj3msPvVqXpEGgTqf1xWVhcEJG2eh+VTN7SY i8MOC0jSB9I+RQlHiB6jh5n03rvROj98U7fKKeHC9ogkM8wq87pBuydglY0mPV8MMzst O/+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=5tRnzXYKTkS2M0kMpjkPwqep+DThbcjgh/IT/l957vY=; b=FVxcoRrjo6tg2j93h59bP7SKpzT6hf3nI4T+3sLYu+KgUSQNuvBUb9H56P5Ygq+LMO fxKe1z6BenoM617ATYmpYD86OAkAf/15BC3fo76Er0x7rCnT6WxInTg8H1pTUF5csJej r6Czou71zuYqb0cxnW5YGN0FvAYkE8G5VbRqZD9U6vxVYuAtlVCuJ4eG9ZZVqkvXYud7 HnR9vjagojHN6cTcV8N5ONS7+IDdUHC8vSMxnp3lJh8KPykXVj4We2q2kVcFkU02D0XE FkHz0QhGiTUrM2fRIQRsYQ9nsGiojafVPgaUx98+hR4/EZxhlJYLUuwcv2aAEU2GdGvA BsJw== X-Gm-Message-State: AE9vXwNaBS/XzUM3HBozBUVUWnkhWdB/SyqtdBb21W+dJChRf9OdQhb/rAtsSjmxiphegA== X-Received: by 10.28.153.70 with SMTP id b67mr17575384wme.84.1472575564427; Tue, 30 Aug 2016 09:46:04 -0700 (PDT) Date: Tue, 30 Aug 2016 17:46:01 +0100 From: Stephane Chazelas To: Peter Stephenson Cc: Zsh hackers list Subject: Re: [PATCHv2] [bug] $SHLVL decremented for the last command of a subshell Message-ID: <20160830164601.GA50437@chaz.gmail.com> Mail-Followup-To: Peter Stephenson , Zsh hackers list References: <20160822061723.GA7308@chaz.gmail.com> <20160829155156.GB17700@chaz.gmail.com> <160829185505.ZM8699@torch.brasslantern.com> <20160830124426.GA15615@chaz.gmail.com> <20160830140457.74d9d32d@pwslap01u.europe.root.pri> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160830140457.74d9d32d@pwslap01u.europe.root.pri> User-Agent: Mutt/1.5.21 (2010-09-15) 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