From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19672 invoked by alias); 10 Sep 2017 16:49:40 -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: 41661 Received: (qmail 7658 invoked by uid 1010); 10 Sep 2017 16:49:40 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-9.server.virginmedia.net 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(80.0.253.73):SA:0(-4.7/5.0):. Processed in 6.713901 secs); 10 Sep 2017 16:49:40 -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=-4.7 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Originating-IP: [86.21.219.59] X-Authenticated-User: p.w.stephenson@ntlworld.com X-Spam: 0 X-Authority: v=2.1 cv=aJkN0uJm c=1 sm=1 tr=0 a=utowdAHh8RITBM/6U1BPxA==:117 a=utowdAHh8RITBM/6U1BPxA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=x7bEGLp0ZPQA:10 a=pGLkceISAAAA:8 a=npldXguGAAAA:8 a=t3pxSufGg_WrRoB3BJoA:9 a=CjuIK1q_8ugA:10 a=1Z6EAcxPEhoA:10 a=6kGIvZw6iX1k4Y-7sg4_:22 a=1MEZn5qd6kv58cYvHi58:22 Date: Sun, 10 Sep 2017 17:42:24 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Cc: Yuya Amemiya Subject: Re: z parameter expansion flag is broken? Message-ID: <20170910174224.54ed65f6@ntlworld.com> In-Reply-To: <20170909.041303.1592547893142420542.ghostrevery@gmail.com> References: <20170909.041303.1592547893142420542.ghostrevery@gmail.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ntlworld.com; s=meg.feb2017; t=1505061745; bh=jIQolgbV/it4eWAOv35OD0Dao90t2iQk4xHaTJ87c2k=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=dAM7GTjjHafY75f32WIQsXe6RK544XJ3bmIUxj3YFQgyVN07W38TaQyzPbDbmTRUs AP6d1wXJvvLvoUERzHNknm8hFPTCh1noGzaIRmjbcjaxDqgcKbe+elSVttW7R3HBLd JQ2cdGU5Pb8IRWygMeSeMqetbvAC/4g4oEErgzw+V02mJ3ZEYqrlz9Ky1LSPAV3fZn BqJEBHuVqsrtDdi06f1hUDjwKMNTlAUGuwo4vrGLZFxm470gSppkH5lN+rQ4pWA3oj FNo3KxNJaywbumJDEVNmGDaO6YUI0hTJ4No7X+S2hnTZOg3isibD5nhaYgJZ+/WB1D +qAfdspaQtOOA== On Sat, 09 Sep 2017 04:13:03 +0900 (JST) Yuya Amemiya wrote: > Why does z parameter expansion flag remove leading '-' from result? > > in zsh 5.4.1 > > ``` > $ echo ${(z):--a} > a That's a bug, but the only new feature is that it now additionally affects "-" because that's tokenized. The basic effect is old: % zsh-5.3.1 -f % setopt nonomatch % echo ${(z):-foo*bar} foobar Because "-" doesn't usually need quoting, it's more noticeable than with other metacharacters. Untokenizing before passing to bufferwords() is the easy fix, and the result can only be better because anything altered would previously simply have been dumped by the effect noted by Bart. However, I'm not at all convinced bufferwords() needs to dump token characters in this case --- bufferwords() is a hack that originated as a helper for completion but is now more widely used. A more elegant solution (not on the cards) wouldn't use bufferwords() at all. pws diff --git a/Src/subst.c b/Src/subst.c index 5b1bf89..5df2a8b 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -3747,11 +3747,15 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, if (isarr) { char **ap; - for (ap = aval; *ap; ap++) + for (ap = aval; *ap; ap++) { + untokenize(*ap); list = bufferwords(list, *ap, NULL, shsplit); + } isarr = 0; - } else + } else { + untokenize(val); list = bufferwords(NULL, val, NULL, shsplit); + } if (!list || !firstnode(list)) val = dupstring(""); diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst index 3c93990..8dbc1e8 100644 --- a/Test/D04parameter.ztst +++ b/Test/D04parameter.ztst @@ -2200,3 +2200,10 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888 >Option >Regular text >Option + + (setopt nonomatch + print ${(z):-foo-bar*thingy?} + ) +0:(z) splitting with remaining tokens +>foo-bar*thingy? +