Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Unexpected ${%F{}} evaluation
- X-seq: zsh-workers 33838
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Unexpected ${%F{}} evaluation
- Date: Wed, 3 Dec 2014 14:55:27 -0800
- In-reply-to: <20141203222002.48d9e22b@mlap.lactee>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20141203222002.48d9e22b@mlap.lactee>
On Wed, Dec 3, 2014 at 1:20 PM, Marc Finet <m.dreadlock@xxxxxxxxx> wrote:
> Hello,
>
> # x="${(%):-%F{red}}XX"; echo $x
> }XX
> # x=${(%):-%F{red}}XX; echo $x
> XX
>
> My questions are the following:
> - is this behavior intended, i.e. break an expression inside ${} to
> the first } ?
Yes, I believe so. Inside double quotes, the second open brace has no
special meaning, so the first close brace that is encountered closes
the parameter expansion.
> At first, I thought that it was a limitation (of ""), but
> testing the second case showed me that correct parsing could be done.
I think the second case is parsed "correctly" only by accident. In
the second case the braces are initially parsed as a brace expansion,
but as a special case a brace expansion with only one element is
replaced by the literal string including the braces. If you "unsetopt
braceexpand" you get the first result for both examples.
It could be argued that this is a bug in braceexpand.
> - is it normal that %F{xx works as %F{xx} ?
In prompts a percent-expando can end at either the closing brace or
the end of the string, whichever comes first ... because it doesn't
seem useful to have the prompt report a syntax error. %F{xx would not
work that way if there were more prompt string following it.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author