Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Parameter + prompt expansion %D{%T.%.} parser issue



On Mon, Jul 18, 2016 at 10:31 PM, Roland Eggner
<edvz2@xxxxxxxxxxxxxxxxxx> 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



Messages sorted by: Reverse Date, Date, Thread, Author