From: Mikael Magnusson <mikachu@gmail.com>
To: Marc Finet <m.dreadlock@gmail.com>
Cc: zsh workers <zsh-workers@zsh.org>
Subject: Re: Unexpected ${%F{}} evaluation
Date: Thu, 4 Dec 2014 03:22:58 +0100 [thread overview]
Message-ID: <CAHYJk3RU5=7TXDvKYXjs7Xe+UDTZNo20T9ZRi8990u9Uk08brg@mail.gmail.com> (raw)
In-Reply-To: <20141203222002.48d9e22b@mlap.lactee>
On Wed, Dec 3, 2014 at 10:20 PM, Marc Finet <m.dreadlock@gmail.com> wrote:
> Hello,
>
> While hacking a small script I fall on the following case:
>
> # x="${(%):-%F{red}}XX"; echo $x
> }XX
> # x=${(%):-%F{red}}XX; echo $x
> XX
>
> 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} ?
>
> Thanks,
>
> Marc.
To answer the unasked question, since Bart already answered,
% x="${(%):-%F{red\}X%F{green\}X%~}"; echo -E $x
and
% x=${(%):-%F\{red\}X%F\{green\}X%~}; echo -E $x
both work "as expected". (the -E is just to convince myself no stray
backslashes are left).
--
Mikael Magnusson
next prev parent reply other threads:[~2014-12-04 2:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-03 21:20 Marc Finet
2014-12-03 22:55 ` Bart Schaefer
2014-12-04 2:22 ` Mikael Magnusson [this message]
2014-12-06 20:03 ` Marc Finet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHYJk3RU5=7TXDvKYXjs7Xe+UDTZNo20T9ZRi8990u9Uk08brg@mail.gmail.com' \
--to=mikachu@gmail.com \
--cc=m.dreadlock@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).