Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: parameter expansion within a string not working?
- X-seq: zsh-users 11215
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: "Pax Unix" <paxunix@xxxxxxxxx>
- Subject: Re: parameter expansion within a string not working?
- Date: Tue, 20 Feb 2007 23:24:54 +0000
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <44613de00702201440k44c8087fy17b6616be11de1be@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <44613de00702201440k44c8087fy17b6616be11de1be@xxxxxxxxxxxxxx>
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