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

Re: b='${a//"/}' and ${(e)b}



On Sat, May 10, 2008 at 10:12:41AM -0700, Bart Schaefer wrote:
[...]
> } $ a='a"b'
> } $ b='${a//"/}'
> } $ echo ${(e)b}
> 
> (etc.)
> 
> If you use
> 
> $ echo ${(Xe)b}
> 
> Then you'll see that zsh burps "parse error" on nearly every one of those
> expressions.  Without the (X) flag the error is silently ignored and the
> expansion returns nothing.  (Perhaps zmv should use (X).)
> 
> Now, as to why it's hard to quote a double quote within a // replacement
> when using the (e) flag, I'm not sure what to say except that the parsing
> rules for all those nested levels of sometimes-implicit quoting get a bit
> arcane.
> 
> } How would I do?
> 
> $ c='"'
> $ b='${a//$c/}'
> $ print ${(Xe)b}
> 
> Which does work for zmv:

Hi Bart,

yes, that's what I had eventually found out as well (here's the
comp.unix.shell discussion that started it:
http://groups.google.com/group/comp.unix.shell/msg/df86a6f26b8ed168)

I now also find that

b='${a//"\""/}'

works.

That doesn't sound quite right though.

-- 
Stéphane



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