Subject: Re: Parameter + prompt expansion %D{%T.%.} parser issue
From: Mikael Magnusson <[email-masked]>
To: Roland Eggner <[email-masked]>, zsh workers <[email-masked]>
Date: Tue, 19 Jul 2016 02:21:39 +0200
List-Id: Zsh Workers List <zsh-workers.zsh.org>

On Mon, Jul 18, 2016 at 10:31 PM, Roland Eggner
<[email-masked]> wrote:
> emulate -R zsh -c 'print -l ${(%):-%D{%T.%.} %~} "${(%):-%D{%T.%.} %~}" ${(%):-"%D{%T.%.} %~"}'
>
> Expected:
> 22:03:02.324 ~
> 22:03:02.324 ~
> 22:03:02.324 ~
>
> Observed:
> 22:03:02.324 ~
> 22:03:02.324 %~}
> 22:03:02.324 ~
>
>
> Note the trailing “%~}” in the 2nd line.
>
> ZSH_PATCHLEVEL=zsh-5.2-282-ga22f4ea
> uname -m -o
> x86_64 GNU/Linux
>
> Usage error?  Bug?  Feature?

Usage error, but it's kind of hard to understand what's going on there
admittedly. When ${} is unquoted, then the parser "knows" which {}
belong together, but when you have them under double quotes the {} for
the %D are not special in any way, so the terminating } for %D matches
the ${ as well. You need "${(%):-%D{%T.%.\} %~}" (It would also be a
good idea to use -r for print when testing quoting things although in
this case it makes no difference.)

The same thing happens when you use %F{} etc.

-- 
Mikael Magnusson