1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-01 05:16:05 +01:00

37096: Another $${(P)...} tweak.

Make a top level (P) work with nested ones, i.e. ${(P)${(P)...}...}
This commit is contained in:
Peter Stephenson 2015-11-12 14:28:15 +00:00
parent 7a951ef93e
commit d814071b14
3 changed files with 26 additions and 3 deletions

View file

@ -1,3 +1,11 @@
2015-11-12 Peter Stephenson <p.stephenson@samsung.com>
* 37096: Src/subst.c, Test/D04parameter.ztst: make top-level
${(P)...} with nested ${(P)...} to the right thing.
* 37094: Src/subst.c, Test/D04parameter.ztst: Further tweaks to
parameter name references: array safety; nested parameters; tests.
2015-11-11 Peter Stephenson <p.stephenson@samsung.com>
* 37092: Doc/Zsh/expn.yo, Src/Zle/compctl.c,

View file

@ -1741,6 +1741,12 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
* simply removed.
*/
int ms_flags = 0;
/*
* We need to do an extra fetch to honour the (P) flag.
* Complicated by the use of subexpressions that may have
* nested (P) flags.
*/
int fetch_needed;
*s++ = '\0';
/*
@ -2325,9 +2331,18 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
s = dyncat(val, s);
/* Now behave po-faced as if it was always like that... */
subexp = 0;
}
/*
* If this is a (P) (first test) and at the top level
* (second test) we can't rely on the caller fetching
* the result from the pending aspar. So do it below.
*/
fetch_needed = aspar && !(pf_flags & PREFORK_SUBEXP);
} else
fetch_needed = 0; /* any initial aspar fetch already done */
v = (Value) NULL;
} else if (aspar) {
} else
fetch_needed = aspar; /* aspar fetch still needed */
if (fetch_needed) {
/*
* No subexpression, but in any case the value is going
* to give us the name of a parameter on which we do

View file

@ -1840,7 +1840,7 @@
local two=three
local three=four
local -a four=(all these worlds belong to foo)
print ${${(P)${(P)${(P)one}}}}
print ${(P)${(P)${(P)one}}}
print ${${(P)${(P)${(P)one}}}[3]}
}
testfn