mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-03 10:21:46 +02:00
zsh-workers/7539
This commit is contained in:
parent
a17bcbc45e
commit
ffa18a29ab
2 changed files with 31 additions and 0 deletions
|
@ -587,6 +587,10 @@ Quote the resulting words with backslashes.
|
|||
item(tt(Q))(
|
||||
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)).
|
||||
)
|
||||
item(tt(X))(
|
||||
With this flag parsing errors occuring with the tt(Q) flag or the
|
||||
pattern matching forms such as `tt(${)var(name)tt(#)var(pattern)tt(})'
|
||||
|
|
27
Src/subst.c
27
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;
|
||||
|
|
Loading…
Reference in a new issue