From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29759 invoked from network); 13 Feb 2006 19:34:25 -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 19:34:25 -0000 Received: (qmail 96192 invoked from network); 13 Feb 2006 19:34:14 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 13 Feb 2006 19:34:13 -0000 Received: (qmail 14287 invoked by alias); 13 Feb 2006 19:34:02 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22265 Received: (qmail 14109 invoked from network); 13 Feb 2006 19:33:59 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 13 Feb 2006 19:33:59 -0000 Received: (qmail 93584 invoked from network); 13 Feb 2006 19:33:59 -0000 Received: from cluster-c.mailcontrol.com (168.143.177.190) by a.mx.sunsite.dk with SMTP; 13 Feb 2006 19:33:56 -0000 Received: from exchange03.csr.com (uuk202166.uk.customer.alter.net [62.189.241.194] (may be forged)) by rly02c.srv.mailcontrol.com (MailControl) with ESMTP id k1DJXrf6007165 for ; Mon, 13 Feb 2006 19:33:53 GMT Received: from csr.com ([10.103.143.38]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Mon, 13 Feb 2006 19:33:53 +0000 To: Zsh hackers list Subject: Re: PATCH: fixing ${1+"$@"} when word-splitting In-reply-to: <20060213190001.GD6952@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> Comments: In-reply-to Wayne Davison message dated "Mon, 13 Feb 2006 11:00:01 -0800." Date: Mon, 13 Feb 2006 19:33:43 +0000 From: Peter Stephenson Message-ID: X-OriginalArrivalTime: 13 Feb 2006 19:33:53.0282 (UTC) FILETIME=[6C2E6E20:01C630D4] Content-Type: text/plain MIME-Version: 1.0 X-Scanned-By: MailControl A-06-00-02 (www.mailcontrol.com) on 10.67.0.112 Wayne Davison wrote: > > % fn() { local IFS=.-; print -l ${=1:-$ZSH_VERSION}; } > > % fn > > 4.3.0-dev-3 > > The attached patch fixes this by temporarily setting SHWORDSPLIT > during the multsub() call when '=' was specified. I also tested > that this change works properly with ${=1:-"$ZSH_VERSION"} (i.e. > giving the output above). is-at-least is now happy. Here's an add-on test that handles a lot of the possibilities. I think the results are all correct. --- Test/D04parameter.ztst.old 2006-02-13 19:21:32.000000000 +0000 +++ Test/D04parameter.ztst 2006-02-13 19:31:10.000000000 +0000 @@ -549,7 +549,7 @@ set Make sure "this test keeps" on "preserving all" quoted whitespace print -l ${=1+"$@"} -0:Regression test of unfixed ${=1+"$@"} bug +0:Regression test of ${=1+"$@"} bug >Make >sure >this test keeps @@ -558,6 +558,103 @@ >quoted >whitespace + 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++ )) print $SHLVL -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php