zsh-workers
 help / color / mirror / code / Atom feed
From: Marc Finet <m.dreadlock@gmail.com>
To: zsh-workers@zsh.org
Subject: Unexpected ${%F{}} evaluation
Date: Wed, 3 Dec 2014 22:20:02 +0100	[thread overview]
Message-ID: <20141203222002.48d9e22b@mlap.lactee> (raw)

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.


             reply	other threads:[~2014-12-03 22:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-03 21:20 Marc Finet [this message]
2014-12-03 22:55 ` Bart Schaefer
2014-12-04  2:22 ` Mikael Magnusson
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=20141203222002.48d9e22b@mlap.lactee \
    --to=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).