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

Prompt expansion: $((%)foo} != $(print -P $foo)



The order in which parameter expansion vs. prompt %x expansion takes place
appears to be reversed for ${(%)...} and $(print -P ...).  This is visible
in this situation:

zsh% setopt promptsubst
zsh% PS1='%$[COLUMNS-20]>...%% >some text here %% '
some text here %

The prompt and the output of "print -P" are truncated at COLUMNS-20, so in
that case the $[...] was expanded before %N>...> was parsed.  However:

some text here % echo ${(%)PS1}
[COLUMNS-1]some text here %

There, %$ was taken as a prompt token (and ignored) before parameters were
expanded.  A workaround is to use ${(%)${(e)PS1}}, but of course that's not
right when promptsubst is NOT set.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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