Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: b='${a//"/}' and ${(e)b}
- X-seq: zsh-workers 24989
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Subject: Re: b='${a//"/}' and ${(e)b}
- Date: Sat, 10 May 2008 10:12:41 -0700
- In-reply-to: <20080510123843.GA5560@xxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20080510123843.GA5560@xxxxxxxxxxxxxxx>
On May 10, 1:38pm, Stephane Chazelas 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:
$ zmv -n '*"*' '${f//$c/}'
mv -- a\"b ab
Or you can do this:
$ zmv -n '*"*' '$f:gs/"//'
mv -- a\"b ab
The parsing rules for :s are a lot simpler than those for ${...}.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author