From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28277 invoked from network); 13 Feb 2006 20:11:33 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 13 Feb 2006 20:11:33 -0000 Received: (qmail 42493 invoked from network); 13 Feb 2006 20:11:26 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 13 Feb 2006 20:11:26 -0000 Received: (qmail 22322 invoked by alias); 13 Feb 2006 20:11:24 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22267 Received: (qmail 22312 invoked from network); 13 Feb 2006 20:11:22 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 13 Feb 2006 20:11:22 -0000 Received: (qmail 42210 invoked from network); 13 Feb 2006 20:11:22 -0000 Received: from dsl3-63-249-88-2.cruzio.com (HELO dot.blorf.net) (63.249.88.2) by a.mx.sunsite.dk with SMTP; 13 Feb 2006 20:11:21 -0000 Received: by dot.blorf.net (Postfix, from userid 1000) id 759BD5EDD; Mon, 13 Feb 2006 12:11:21 -0800 (PST) Date: Mon, 13 Feb 2006 12:11:21 -0800 From: Wayne Davison To: Peter Stephenson Cc: Zsh hackers list Subject: Re: PATCH: fixing ${1+"$@"} when word-splitting Message-ID: <20060213201121.GG6952@dot.blorf.net> References: <20060211181440.GA30984@dot.blorf.net> <200602122026.k1CKQHGH003629@pwslaptop.csr.com> <20060213105349.GD31780@dot.blorf.net> <20060213174338.GC6952@dot.blorf.net> <20060213190001.GD6952@dot.blorf.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="0QFb0wBpEddLcDHQ" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.11 --0QFb0wBpEddLcDHQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Feb 13, 2006 at 07:33:43PM +0000, Peter Stephenson wrote: > Here's an add-on test that handles a lot of the possibilities. I think > the results are all correct. Looks good to me. I also added a couple tests. The combination of both our changes relative to CVS is attached. ..wayne.. --0QFb0wBpEddLcDHQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="d04.patch" --- Test/D04parameter.ztst 11 Oct 2005 16:48:06 -0000 1.13 +++ Test/D04parameter.ztst 13 Feb 2006 20:04:16 -0000 @@ -547,20 +547,128 @@ >shell >again - set If "this test fails" maybe "we have finally fixed" the shell + local sure_that='sure that' varieties_of='varieties of' one=1 two=2 + set Make $sure_that "this test keeps" on 'preserving all' "$varieties_of" quoted whitespace print -l ${=1+"$@"} -0:Regression test of unfixed ${=1+"$@"} bug ->If ->this ->test ->fails ->maybe ->we ->have ->finally ->fixed ->the ->shell + print -l ${=1+Make $sure_that "this test keeps" on 'preserving all' "$varieties_of" quoted whitespace} + print -l ${=1+$one $two} +0:Regression test of ${=1+"$@"} bug and some related expansions +>Make +>sure that +>this test keeps +>on +>preserving all +>varieties of +>quoted +>whitespace +>Make +>sure +>that +>this test keeps +>on +>preserving all +>varieties of +>quoted +>whitespace +>1 +>2 + + splitfn() { + local IFS=.- + local foo=1-2.3-4 + # + print "Called with argument '$1'" + print "No quotes" + print -l ${=1:-1-2.3-4} ${=1:-$foo} + print "With quotes on default argument only" + print -l ${=1:-"1-2.3-4"} ${=1:-"$foo"} + } + print 'Using "="' + splitfn + splitfn 5.6-7.8 + # + splitfn() { + emulate -L zsh + setopt shwordsplit + local IFS=.- + local foo=1-2.3-4 + # + print "Called with argument '$1'" + print "No quotes" + print -l ${1:-1-2.3-4} ${1:-$foo} + print "With quotes on default argument only" + print -l ${1:-"1-2.3-4"} ${1:-"$foo"} + } + print Using shwordsplit + splitfn + splitfn 5.6-7.8 +0:Test of nested word splitting with and without quotes +>Using "=" +>Called with argument '' +>No quotes +>1 +>2 +>3 +>4 +>1 +>2 +>3 +>4 +>With quotes on default argument only +>1-2.3-4 +>1-2.3-4 +>Called with argument '5.6-7.8' +>No quotes +>5 +>6 +>7 +>8 +>5 +>6 +>7 +>8 +>With quotes on default argument only +>5 +>6 +>7 +>8 +>5 +>6 +>7 +>8 +>Using shwordsplit +>Called with argument '' +>No quotes +>1 +>2 +>3 +>4 +>1 +>2 +>3 +>4 +>With quotes on default argument only +>1-2.3-4 +>1-2.3-4 +>Called with argument '5.6-7.8' +>No quotes +>5 +>6 +>7 +>8 +>5 +>6 +>7 +>8 +>With quotes on default argument only +>5 +>6 +>7 +>8 +>5 +>6 +>7 +>8 unset SHLVL (( SHLVL++ )) --0QFb0wBpEddLcDHQ--