From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: PATCH: nested ${(P)} (formerly SHWORDSPLIT and leading spaces)
Date: Thu, 12 Nov 2015 14:19:27 +0000 [thread overview]
Message-ID: <20151112141927.294984d9@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20151112094628.7345465b@pwslap01u.europe.root.pri>
On Thu, 12 Nov 2015 09:46:28 +0000
Peter Stephenson <p.stephenson@samsung.com> wrote:
> > + print ${${(P)${(P)${(P)one}}}}
>
> Well, one thing that isn't natural is that when you're relying on the
> new logic you need that extra ${...} wrapper even in the first of the
> two cases to trigger the recursive (P).
Seems to work via the obvious fix.
diff --git a/Src/subst.c b/Src/subst.c
index c1369b5..b7f8338 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
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 6f325d2..210c0d8 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -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
next prev parent reply other threads:[~2015-11-12 14:19 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-06 10:54 Inconsistency with SHWORDSPLIT and leading spaces Christian Neukirchen
2015-11-06 17:00 ` Peter Stephenson
2015-11-07 17:42 ` Peter Stephenson
2015-11-07 19:43 ` Bart Schaefer
2015-11-08 18:18 ` Peter Stephenson
2015-11-08 18:55 ` Bart Schaefer
2015-11-09 6:03 ` Bart Schaefer
2015-11-11 17:49 ` PATCH: nested ${(P)} (formerly SHWORDSPLIT and leading spaces) Peter Stephenson
2015-11-11 18:13 ` Bart Schaefer
2015-11-11 21:55 ` Peter Stephenson
2015-11-12 9:46 ` Peter Stephenson
2015-11-12 14:19 ` Peter Stephenson [this message]
2015-11-13 8:17 ` Jun T.
2015-11-13 15:07 ` Jun T.
2015-11-14 1:33 ` Bart Schaefer
2015-11-14 9:45 ` Peter Stephenson
2015-11-14 18:51 ` Bart Schaefer
[not found] <0faa0ee3-303a-4cb5-a270-d3d1787accf1@email.android.com>
2015-11-15 5:14 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151112141927.294984d9@pwslap01u.europe.root.pri \
--to=p.stephenson@samsung.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).