From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23559 invoked by alias); 30 Aug 2016 17:10:49 -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: 39127 Received: (qmail 28271 invoked from network); 30 Aug 2016 17:10:49 -0000 X-Qmail-Scanner-Diagnostics: from mailout4.w1.samsung.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(210.118.77.14):SA:0(-1.5/5.0):. Processed in 0.40752 secs); 30 Aug 2016 17:10:49 -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=-1.5 required=5.0 tests=RP_MATCHES_RCVD autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: p.stephenson@samsung.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at samsung.com does not designate permitted sender hosts) X-AuditID: cbfec7f5-f792e6d0000013f5-d3-57c5bbb36fb5 Date: Tue, 30 Aug 2016 18:00:32 +0100 From: Peter Stephenson To: Zsh hackers list Subject: Re: [PATCHv2] [bug] $SHLVL decremented for the last command of a subshell Message-id: <20160830180032.199eae0a@pwslap01u.europe.root.pri> In-reply-to: <20160830164601.GA50437@chaz.gmail.com> 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> <20160830164601.GA50437@chaz.gmail.com> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrALMWRmVeSWpSXmKPExsVy+t/xq7qbdx8NN7jSq21xsPkhkwOjx6qD H5gCGKO4bFJSczLLUov07RK4Ml5caWYpOMJZ0bEiqIHxEHsXIyeHhICJxMHGU8wQtpjEhXvr 2boYuTiEBJYyStxesRqsSEhgBpPE7xtWEIlzjBL/1z9ihHDOMkqc/dTACFLFIqAqcerUb1YQ m03AUGLqptlgcREBLYkdJ08ygdjCAiEST/7dYwGxeQXsJZbMvs8GYnMCnTHr5Umo1VOZJKZs Xw42iF9AX+Lq309MEPfZS8y8coYRollQ4sdkiEHMQAs2b2tihbDlJTavecsMcba6xI27u9kn MArPQtIyC0nLLCQtCxiZVzGKppYmFxQnpeca6RUn5haX5qXrJefnbmKEhPPXHYxLj1kdYhTg YFTi4T0w62i4EGtiWXFl7iFGCQ5mJRFewa1AId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rwzd70P ERJITyxJzU5NLUgtgskycXBKNTCe/6zdZftdLFlDU+19VeP84gl8RqcOJO9z+uy6ZeetnX+3 OBqGc4Zv2LCmwvqhrM6a4kss8zri1wdX6HBLzeVetHrz1Xa3qgsFLW47QrdwRdzbaVm789mO d6EMV5SZ7fZvv3yvpdpprZu+1dK5EQkLJ94uKH+4VjTwrnvFwo0TPz+ZmPy2csdEJZbijERD Leai4kQA23qSq2MCAAA= On Tue, 30 Aug 2016 17:46:01 +0100 Stephane Chazelas wrote: > 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 When this was introduced in zsh, there was some controversy over whether it was the right thing to do. I decided it was on the basis that the "level" is how deep you are in the process hierarchy, rather than how many processes have previously been executed to get where you are, seeing as the latter isn't really visible in the current context. But I'm not aware of any requirement specification [remember those?] saying what the purpose of SHLVL is. pws