Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Unexpected ${%F{}} evaluation
- X-seq: zsh-workers 33839
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Marc Finet <m.dreadlock@xxxxxxxxx>
- Subject: Re: Unexpected ${%F{}} evaluation
- Date: Thu, 4 Dec 2014 03:22:58 +0100
- Cc: zsh workers <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=QUuGyXhQxo35eMnAd/NChpPYr3WFs+j0p3tqzwnVB6o=; b=hYc3q547h/KVh+r0B6rJNmIZmTiYFLq+nCiuFg+XfFaFfgJgP/QC93bfY5WG/kdKIg CEfK3PDQfZLIYxzMwC6TxDIayBH9ZPDj5LNQSvzDlPXrbU8vnEiY9tAYgnLMzupefK35 Pev02+SLQ/sS7g10qbxTp90tG4eJU0misDRbnkSdlgYi8ZJhVy1+2Z1PXYhOpIgFxPDV Dy67x5Spm30XE4jaKMX5Ll3Cf5vWdrB7lXCn0q2eaFSJxJoX6vGnc/gAWMRsEifr7Pqw 1Co82xvfXywxKCPaLvnwbyFLgLAhZ4PSXsRUCQ7eqFAgYq15e6VVdo9vScZ9D70eLBJu 1qlA==
- 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 10:20 PM, Marc Finet <m.dreadlock@xxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author