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

Unexpected ${%F{}} evaluation


While hacking a small script I fall on the following case:

    # x="${(%):-%F{red}}XX"; echo $x
    # x=${(%):-%F{red}}XX; echo $x

In both cases, the color was correct, i.e. (%) + %F{} did it job, but
note the extra } in the first case.
It seems that the double-quotes of the first case associated the first
'}' to the '${': its value is Outbrace in stringsubst(). The '{' after 
the %F and the second '}' remain {}, and the first { is Inbrace. 

In the second case, the two '}' are converted into Outbrace, and both
'{' are also converted into Inbrace.

For the first case, {} are not balanced according to what I expected,
(outer {} for $ and inner {} for %F), but first } for first {, i.e. ${}. 

My questions are the following:
 - is this behavior intended, i.e. break an expression inside ${} to
   the first } ? At first, I thought that it was a limitation (of ""), but
   testing the second case showed me that correct parsing could be done.
 - is it normal that %F{xx works as %F{xx} ?



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