zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Unexpected ${%F{}} evaluation
Date: Wed, 3 Dec 2014 14:55:27 -0800	[thread overview]
Message-ID: <CAH+w=7brHx8FYjw5iiTuwq7sKPzAMXR1VcDfpkgnn+u+dC3JOg@mail.gmail.com> (raw)
In-Reply-To: <20141203222002.48d9e22b@mlap.lactee>

On Wed, Dec 3, 2014 at 1:20 PM, Marc Finet <m.dreadlock@gmail.com> 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.


  reply	other threads:[~2014-12-03 22:55 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 [this message]
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='CAH+w=7brHx8FYjw5iiTuwq7sKPzAMXR1VcDfpkgnn+u+dC3JOg@mail.gmail.com' \
    --to=schaefer@brasslantern.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).