From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22886 invoked by alias); 28 Apr 2017 09:03:51 -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: 41020 Received: (qmail 29684 invoked from network); 28 Apr 2017 09:03:51 -0000 X-Qmail-Scanner-Diagnostics: from mailout3.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.13):SA:0(-5.0/5.0):. Processed in 1.154208 secs); 28 Apr 2017 09:03:51 -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=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RP_MATCHES_RCVD,SPF_HELO_PASS 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-f79806d000001279-ec-5903056e2215 Date: Fri, 28 Apr 2017 10:03:38 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: PATCH: perform expansion for precommand modifiers Message-id: <20170428100338.27ef869c@pwslap01u.europe.root.pri> In-reply-to: <170427161300.ZM23462@torch.brasslantern.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+NgFnrLIsWRmVeSWpSXmKPExsWy7djP87p5rMyRBju+c1kcbH7I5MDoserg B6YAxigum5TUnMyy1CJ9u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hgGIzSKgKjH74Q0WEJtNwFBi6qbZ YGNFBMQlzq49DxYXFrCTmLtvO1gvr4C9xJPOO2wgNqeAlUTjjnYmiAV3mCSe/lnIBJLgF9CX uPr3ExPEffYSM69A3MorICjxY/I9sKHMAloSm7c1sULY8hKb17yFOk5d4sbd3ewTGIVnIWmZ haRlFpKWBYzMqxhFUkuLc9Nziw31ihNzi0vz0vWS83M3MQKjaNuxn5t3MF7aGHyIUYCDUYmH l+EDY6QQa2JZcWXuIUYJDmYlEd7OP0yRQrwpiZVVqUX58UWlOanFhxhNgSEzkVlKNDkfGOF5 JfGGJobmloZGxhYW5kZGSuK8JR+uhAsJpCeWpGanphakFsH0MXFwSjUwTs+zYO+6tv30AYUZ CyTu/Zpw9XqK+kMG832lf6sEF5xp2m0UlG4su26y3PuKea+tXf0/vkjdIX37y8/8HTedjjxT lzCb52HHHef8N/9Y099XTNvvm29r6pV8/LbCvjJE3Kl1zuKZXJqHfTVyy7O7/i9SmXqwMXyJ 5/7MTQ6VhTyTnPcY/5c/pMRSnJFoqMVcVJwIAAval324AgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170428090341eucas1p2b705620bf590b2c3d24c6a4b0495713d 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: 20170425091533eucas1p26af70366557848059af3b7c8957f1d55 X-RootMTR: 20170425091533eucas1p26af70366557848059af3b7c8957f1d55 References: <20170425101520.23910ede@pwslap01u.europe.root.pri> <20170426194517.GA12961@fujitsu.shahaf.local2> <170426142508.ZM19385@torch.brasslantern.com> <20170427094018.27eafa6a@pwslap01u.europe.root.pri> <170427161300.ZM23462@torch.brasslantern.com> On Thu, 27 Apr 2017 16:12:59 -0700 Bart Schaefer wrote: > On Apr 27, 9:40am, Peter Stephenson wrote: > } > } + (\exec /bin/sh -c 'echo Test one'; print Not reached) > } + ('exec' /bin/sh -c 'echo Test two'; print Not reached) > } +0:exec with quotes > } +>Test one > } +>Test two > > This isn't testing the right thing. The complaint was that the -c option > of exec was treated as a command name if the keyword was quoted. I think we can fix this by adding a test for that. > Similarly for "command -p" which now that I try it is still broken: > > torch% \command -p echo > zsh: command not found: -p That's nothing to do with the quoting. I assumed we had a test for -p without -v or -V, but apparently we don't, so I didn't notice there was an extra node to remove. pws diff --git a/Src/exec.c b/Src/exec.c index 978a32d..15f663c 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -2824,7 +2824,7 @@ execcmd_exec(Estate state, Execcmd_params eparams, * Otherwise, just leave marked as BINF_COMMAND * modifier with no additional action. */ - LinkNode argnode, oldnode; + LinkNode argnode, oldnode, pnode = NULL; char *argdata, *cmdopt; int has_p = 0, has_vV = 0, has_other = 0; argnode = firstnode(preargs); @@ -2845,6 +2845,7 @@ execcmd_exec(Estate state, Execcmd_params eparams, * also traditional behaviour. */ has_p = 1; + pnode = argnode; break; case 'v': case 'V': @@ -2882,6 +2883,12 @@ execcmd_exec(Estate state, Execcmd_params eparams, } else if (has_p) { /* Use default path */ use_defpath = 1; + /* + * We don't need this node as we're not treating + * "command" as a builtin this time. + */ + if (pnode) + uremnode(preargs, pnode); } /* * Else just any trailing diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst index 37311ce..9625a15 100644 --- a/Test/A01grammar.ztst +++ b/Test/A01grammar.ztst @@ -116,9 +116,11 @@ (\exec /bin/sh -c 'echo Test one'; print Not reached) ('exec' /bin/sh -c 'echo Test two'; print Not reached) -0:exec with quotes + (\exec -c /bin/sh -c 'echo Test three'; print Not reached) +0:precommand modifiers with quotes >Test one >Test two +>Test three cat() { echo Function cat executed; } command cat && unfunction cat @@ -126,6 +128,14 @@ External command cat executed + (command -p echo this is output) + (\command -p echo this is more output) + ('command' -p echo this is yet more output) +0: command -p without -v or -V +>this is output +>this is more output +>this is yet more output + command -pv cat command -pv echo command -p -V cat