summaryrefslogtreecommitdiff
path: root/Src/subst.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2015-11-12 14:28:15 +0000
committerPeter Stephenson <pws@zsh.org>2015-11-12 14:28:15 +0000
commitd814071b1420418a3243642a5cdeb3946e7d1939 (patch)
treefd24174bec58258a472a47cdde0ce7a7b2cd5dc2 /Src/subst.c
parent7a951ef93ef2cc6baac9ec3b51909ad44e4bfe15 (diff)
downloadzsh-d814071b1420418a3243642a5cdeb3946e7d1939.tar.gz
zsh-d814071b1420418a3243642a5cdeb3946e7d1939.zip
37096: Another $${(P)...} tweak.
Make a top level (P) work with nested ones, i.e. ${(P)${(P)...}...}
Diffstat (limited to 'Src/subst.c')
-rw-r--r--Src/subst.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/Src/subst.c b/Src/subst.c
index c1369b5a7..b7f8338c7 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -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