Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Prompt expansion: $((%)foo} != $(print -P $foo)
- X-seq: zsh-workers 10180
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: Prompt expansion: $((%)foo} != $(print -P $foo)
- Date: Mon, 20 Mar 2000 13:04:13 +0100 (MET)
- In-reply-to: "Bart Schaefer"'s message of Mon, 20 Mar 2000 06:45:19 +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Bart Schaefer wrote:
> 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.
Err... that's what (%%) is for. From the docs:
item(tt(%))(
Expand all tt(%) escapes in the resulting words in the same way as in
prompts (see noderef(Prompt Expansion)). If this flag is given twice,
full prompt expansion is done on the resulting words, depending on the
setting of the tt(PROMPT_PERCENT), tt(PROMPT_SUBST) and
tt(PROMPT_BANG) options.
)
Bye
Sven
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author