From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19034 invoked by alias); 31 Aug 2016 09:02:47 -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: 39139 Received: (qmail 2977 invoked from network); 31 Aug 2016 09:02:45 -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 2.074615 secs); 31 Aug 2016 09:02:45 -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: cbfec7f4-f79cb6d000001359-b1-57c69d2a492c Date: Wed, 31 Aug 2016 10:02:30 +0100 From: Peter Stephenson To: Zsh hackers list Subject: Re: [PATCHv2] [bug] $SHLVL decremented for the last command of a subshell Message-id: <20160831100230.0892bae1@pwslap01u.europe.root.pri> In-reply-to: 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> <20160830180032.199eae0a@pwslap01u.europe.root.pri> 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/xy7pac4+FG7zsFLU42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGXP+XWArOMFXceXWIsYGxgvcXYwcHBICJhJbmzO6GDmBTDGJ C/fWs3UxcnEICSxllPh7/TELhDODSeLj5TVMEM45RoklLYtYQVqEBM4ySrx8HAJiswioSjyd sIERxGYTMJSYumk2mC0ioCWx4+RJJhBbWCBE4sm/eywgNq+AvcTEKWfYQGxOgWCJnYeaoVZP YpbY3HMXrIFfQF/i6t9PTBD32UvMvHKGEaJZUOLHZIhBzEALNm9rYoWw5SU2r3nLDHGcusSN u7vZJzAKz0LSMgtJyywkLQsYmVcxiqaWJhcUJ6XnGuoVJ+YWl+al6yXn525ihITzlx2Mi49Z HWIU4GBU4uHNmHE0XIg1say4MvcQowQHs5II77zZx8KFeFMSK6tSi/Lji0pzUosPMUpzsCiJ 887d9T5ESCA9sSQ1OzW1ILUIJsvEwSnVwMgtvXOHcWUMz8y72nyPsyoZqtuMH/P99b/KNlP1 sV/kGyf9Sdt2d4aIfT5sNyXQabP45QOTktTf//0heMpxcf8Gb6uFq+vf3eDNlF2abdKfu771 ueT8kDPt+Z/OMc3XsRS9/X5OgKCcZP7KPZyOaicuZ336fKGvtlbCPlvTR+j963/hMrPX2Six FGckGmoxFxUnAgABWVrrYwIAAA== On Tue, 30 Aug 2016 20:34:34 +0200 Mikael Magnusson wrote: > > 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. > > For me personally, I just use it in my prompt to indicate whether > typing "exit" will close the terminal or not, eg if I'm inside a > nested actual shell. When I added that I wasn't even aware of any of > the weird rules regarding subshells affecting it. It's not immediately > obvious to me when that is useful... There are no weird *rules* regarding subshells and SHLVL; the rule is SHLVL should indicate how deeply nested the parent shell is in process terms. The effect with subshells was a bug because we do a fake exec (i.e. we don't bother forking for the new last command) with the last process in a subshell because we know the current process will come to an end anyway. The decrement is needed in general on a real exec because you are creating a new shell which isn't more deeply nested, i.e. if you do "exec zsh" from the command line you (probably) expect SHLVL to look the same since the nesting level hasn't changed. If everything is working this is the sole effect (but process management is complicated enough real life isn't necessarily that simple). The final question was whether after the fix there was any remaining business to do with the combination of execs and subshells, but it doesn't look like there is anything significant. pws