Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: fixing ${1+"$@"} when word-splitting
- X-seq: zsh-workers 22265
- From: Peter Stephenson <pws@xxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Subject: Re: PATCH: fixing ${1+"$@"} when word-splitting
- Date: Mon, 13 Feb 2006 19:33:43 +0000
- In-reply-to: <20060213190001.GD6952@xxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20060211181440.GA30984@xxxxxxxxxxxxx> <200602122026.k1CKQHGH003629@xxxxxxxxxxxxxxxxx> <20060213105349.GD31780@xxxxxxxxxxxxx> <EXCHANGE03NXLbrBmWU0000c118@xxxxxxxxxxxxxxxxxx> <20060213174338.GC6952@xxxxxxxxxxxxx> <EXCHANGE0361Bp2fk8L0000c976@xxxxxxxxxxxxxxxxxx> <20060213190001.GD6952@xxxxxxxxxxxxx>
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 <pws@xxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author