Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: nested ${(P)} (formerly SHWORDSPLIT and leading spaces)



On Wed, 11 Nov 2015 21:55:41 +0000
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> With a little more tweaking, nested references work naturally, if
> "naturally" is the word.  See final test.
>...
> +  testfn() {
> +    local one=two
> +    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}}}[3]}
> +  }

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).  Normally a surrounding level
with no flags, modifications or subscripts has no effect.  You don't
need that for one (P) at the top level, ${(P)...}, because that's going
a different path through the code.

Either I should work out how to fix that or document the difference.
I can't imagine anyone is going to lose sleep.

pws



Messages sorted by: Reverse Date, Date, Thread, Author