Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: Re: expansion
- X-seq: zsh-workers 11944
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx (Zsh hackers list)
- Subject: Re: PATCH: Re: expansion
- Date: Fri, 16 Jun 2000 13:20:54 +0100
- In-reply-to: "Your message of Fri, 16 Jun 2000 13:22:10 +0200." <200006161122.NAA30744@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Sven wrote:
> What's going on here? With -f:
> % a='a{b,c}d'
> % setopt braceccl
> % b=( ${${(q)a}:gs/\\{/{/:gs/\\}/}/} )
> % echo $b
> a,d abd acd
>
> Oops. (Yes, works with just `echo ${${(q)a}...}', too.)
Yes, I'd use this:
print ${${(q)a}:gs/\\\{/\{/:gs/\\\}/\}/}
to make sure all the relevant braces are quoted, or perhaps even better
(pattern matching is better about untokenising, because it only needs to do
it once while parsing):
print ${${(q)a}//(#b)\\([{}])/$match[1]}
This is not very well handled at present; all sorts of things are a bit
more heavily tokenised than you might want at various places in
paramsubst(), because it's very hard to work out in the middle of all the
other streams of logic about substitution.
There's another glitch with braces I haven't looked at but I had to work
around in the parameter tests (possibly the most boring piece of zsh code
ever written):
% array=(once bitten twice shy)
% print IF{${array},THEN}ELSE
IF{once bitten twice shy,THEN}ELSE
Double-quoting ${array} fixes it, even more bizarrely. This doesn't depend
on braceccl. What's more, the full expansion works with RCEXPANDPARAM:
% print IF{${^array},THEN}ELSE
IFonceELSE IFTHENELSE IFbittenELSE IFTHENELSE IFtwiceELSE IFTHENELSE IFshyELSE IFTHENELSE
--
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxxx>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author