Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: parameter expansion within a string not working?



On Tue, 20 Feb 2007 17:40:20 -0500
"Pax Unix" <paxunix@xxxxxxxxx> wrote:
> To demonstrate:
> 
> $ zsh -f -c 'blah=(xa xb ya yb); print ${(t)blah}; print 0${blah:#x*}0'
> array
> 0ya yb0
> 
> as expected.  However:
> 
> $ zsh -f -c 'blah=(xa xb ya yb); print ${(t)blah}; print "0${blah:#x*}0"'
> array
> 00
> 
> which I found rather surprising.  Am I missing something regarding
> expansions within double-quotes?

It's a bit counterintuitive because the double quotes take effect
immediately on the substitution.  So what you're matching on is
the string "xa xb ya yb", the whole of which is removed.  You can force
it to keep the array as an array despite the double quotes with the (@)
flag:

% print "0${(@)blah:#x*}0"
0ya yb0

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author