diff options
Diffstat (limited to 'Src/subst.c')
-rw-r--r-- | Src/subst.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Src/subst.c b/Src/subst.c index 1d739c886..7619c94a9 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -730,6 +730,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub) int arrasg = 0; int eval = 0; int aspar = 0; + int presc = 0; int nojoin = 0; char inbrace = 0; /* != 0 means ${...}, otherwise $... */ char hkeys = 0; @@ -934,6 +935,10 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub) wantt = 1; break; + case '%': + presc = 1; + break; + default: flagerr: zerr("error in flags", NULL, 0); @@ -1569,6 +1574,28 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub) makecapitals(&val); } } + if (presc) { + int len; + + if (isarr) { + char **ap; + + if (!copied) + aval = arrdup(aval), copied = 1; + ap = aval; + for (; *ap; ap++) { + unmetafy(*ap, &len); + *ap = unmetafy(promptexpand(metafy(*ap, len, META_NOALLOC), + 0, NULL, NULL), &len); + } + } else { + if (!copied) + val = dupstring(val), copied = 1; + unmetafy(val, &len); + val = unmetafy(promptexpand(metafy(val, len, META_NOALLOC), + 0, NULL, NULL), &len); + } + } if (quotemod) { if (isarr) { char **ap; |