From bf0452b632d1b051de773143a0f9a3c0a84a61e0 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Tue, 31 Aug 1999 13:57:37 +0000 Subject: zsh-workers/7574 --- Doc/Zsh/expn.yo | 5 ++++- Src/subst.c | 11 +++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo index 3a56bb7ac..429429941 100644 --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -604,7 +604,10 @@ Remove one level of quotes from the resulting words. ) item(tt(%))( Expand all tt(%) escapes in the resulting words in the same way as in -prompts (see noderef(Prompt Expansion)). +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_SUBST) and tt(PROMPT_BANG) options. The +tt(PROMPT_PERCENT) option is temporarily turned on in any case. ) item(tt(X))( With this flag parsing errors occuring with the tt(Q) flag or the diff --git a/Src/subst.c b/Src/subst.c index a3853472c..70e5c1755 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -938,7 +938,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub) break; case '%': - presc = 1; + presc++; break; default: @@ -1659,8 +1659,12 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub) } } if (presc) { - int len; + int ops = opts[PROMPTSUBST], opb = opts[PROMPTBANG]; + int opp = opts[PROMPTPERCENT], len; + opts[PROMPTPERCENT] = 1; + if (presc < 2) + opts[PROMPTSUBST] = opts[PROMPTBANG] = 0; if (isarr) { char **ap; @@ -1679,6 +1683,9 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub) val = unmetafy(promptexpand(metafy(val, len, META_NOALLOC), 0, NULL, NULL), &len); } + opts[PROMPTSUBST] = ops; + opts[PROMPTBANG] = opb; + opts[PROMPTPERCENT] = opp; } if (quotemod) { if (isarr) { -- cgit 1.4.1