From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14179 invoked by alias); 30 Sep 2016 09:36:37 -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: 39517 Received: (qmail 29689 invoked from network); 30 Sep 2016 09:36:37 -0000 X-Qmail-Scanner-Diagnostics: from mailout1.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.11):SA:0(-3.0/5.0):. Processed in 0.505733 secs); 30 Sep 2016 09:36:37 -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=-3.0 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-f791c6d000006eac-49-57ee321c4969 Date: Fri, 30 Sep 2016 10:36:25 +0100 From: Peter Stephenson To: Zsh Hackers' List Subject: Re: Strange parameter visibility Message-id: <20160930103625.0f46aa9d@pwslap01u.europe.root.pri> In-reply-to: <20160930095032.17083e7b@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+NgFnrNIsWRmVeSWpSXmKPExsWy7djP87oyRu/CDa6uMLU42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGdM/bmYrOCtU8aRzD3MD4zm+LkYODgkBE4nuC4JdjJxAppjE hXvr2boYuTiEBJYySvSs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wkdm08zwQx8wKTxNFtDUwgCX4B fYmrfz8xQdxnLzHzyhlGiGZBiR+T74HtYhbQkti8rYkVwpaX2LzmLTOILSSgLnHj7m72CYzC s5C0zELSMgtJywJG5lWMIqmlxbnpucWGesWJucWleel6yfm5mxiBcbTt2M/NOxgvbQw+xCjA wajEwyug/DZciDWxrLgy9xCjBAezkgjvHYN34UK8KYmVValF+fFFpTmpxYcYTYEBM5FZSjQ5 HxjjeSXxhiaG5paGRsYWFuZGRkrivCUfroQLCaQnlqRmp6YWpBbB9DFxcEo1MFo47ugLLzxs aiE089TVR75H6iZ5u23Y6KjOdc3Qfc6F8om3d7AXftJLtanb/Fe+7qJmSt/3uSdblU6IP51x 4ERlXbYU0+aKoBOC11lFlmduMUs1LIjV/XZX52g41yOJtxV6De5ls6I+B0bI9Cpc2j5PdEPG uTuFJ55yr/7XJe5+I+Xpko2GpkosxRmJhlrMRcWJANojSo25AgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20160930093628eucas1p2d645768d748aa140afe2053a8ee58344 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?UGV0ZXIgU3RlcGhlbnNvbhtTQ1NDLURhdGEgUGxhbmUb?= =?UTF-8?B?7IK87ISx7KCE7J6QG1ByaW5jaXBhbCBFbmdpbmVlciwgU29mdHdhcmU=?= X-Global-Sender: =?UTF-8?B?UGV0ZXIgU3RlcGhlbnNvbhtTQ1NDLURhdGEgUGxhbmUbU2Ft?= =?UTF-8?B?c3VuZyBFbGVjdHJvbmljcxtQcmluY2lwYWwgRW5naW5lZXIsIFNvZnR3YXJl?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDA1Q0QwNTAwNTg=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20160917181339eucas1p24d214aa618aa96b5a8ddfbf351598da6 X-RootMTR: 20160917181339eucas1p24d214aa618aa96b5a8ddfbf351598da6 References: <87bmzmtmzq.fsf@alfa.kjonca> <20160929172417.5022a014@pwslap01u.europe.root.pri> <20160929180301.5d1930d0@pwslap01u.europe.root.pri> <160929142821.ZM16694@torch.brasslantern.com> <20160930095032.17083e7b@pwslap01u.europe.root.pri> On Fri, 30 Sep 2016 09:50:32 +0100 Peter Stephenson wrote: > I wonder if that means there are cases where the change is problematic > --- I hadn't realised this also covered assignments before running a > command. Given your experience elsewhere, you might find this makes > pipestatus worse if you test it on relevant shell code, for example. I've now realised WC_ASSIGN just applies to the invididual assignment --- it doesn't actually mark the command line at all, there could in principle be any sort of command after it. So probably the change is unsafe and needs to be backed off at least for now. I'm not sure it's worth scanning down the code and seeing what's next in excpline2(), though that's probably the right thing to do. A more robust fix is a complete refactoring of execcmd(), which is far too big anyway, with the appropriate parts being called form above, deciding on asignments and analysing the commands early, possibly allowing there to be a single fork in one place. However, that's a big job --- and without extra code to delay prefork() I still don't think that fixes the case ": ${x:=2} | echo $x", and I suspect the case "cmd=:; $cmd ${x:=2} | echo $x" is pretty much unfixable without delaying the assignment from the ${x:=2} until a later part of processing, which might have side effects. pws diff --git a/Src/exec.c b/Src/exec.c index e253d7b..2714edb 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -1844,7 +1844,7 @@ execpline2(Estate state, wordcode pcode, /* if we are doing "foo | bar" where foo is a current * * shell command, do foo in a subshell and do the * * rest of the pipeline in the current shell. */ - if ((wc_code(code) >= WC_CURSH || wc_code(code) == WC_ASSIGN) + if ((wc_code(code) >= WC_CURSH) && (how & Z_SYNC)) { int synch[2]; struct timeval bgtime; index 0b1085c..1ad73c5 100644 --- a/Test/A01grammar.ztst +++ b/Test/A01grammar.ztst @@ -757,9 +757,12 @@ >} >Stuff here - x=1 - x=2 | echo $x - echo $x -0:Assignment-only current shell commands in LHS of pipelin ->1 ->1 +## This problem is hard to fix without significant changes to how +## the shell forks for a pipeline. +# +# x=1 +# x=2 | echo $x +# echo $x +# 0:Assignment-only current shell commands in LHS of pipelin +# >1 +# >1