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

Re: Nofork ${{var}...} edge cases



On Wed, Mar 27, 2024 at 3:22 PM Oliver Kiddle <opk@xxxxxxx> wrote:
>
> > Or we could declare ${{REPLY}...} as NOT synonymous with ${|...} and
> > localize REPLY only in the latter of those.  That might actually make
> > more sense.
>
> That definitely makes most sense to me.

Hrm, unfortunately that gets a bit dicey, because ${ ... } relies on
having the magic local $REPLY as a place to stash the captured stdout
long enough for paramsubst() to reach the point of returning it.  So
it would be weird for only ${{var}...} to "unlocalize" REPLY.  Might
have to think about that a bit more.

> If we want automatic local for the subscript then maybe ${{a[]} REPLY=2}

I'm not following how that is meant to work.

> While ${{arr} ... } does return arrays, it doesn't appear to be possible
> to force array output from ${| ... }

Correct, the magic local REPLY is always a scalar.

> In mksh:
>   print ${|REPLY=(one two)}
> does just print "one".

The current dev zsh implementation stringifies the whole array:
% print ${| REPLY=(one two)}
one two

> Perhaps worth including in a test case is the following which does
> break after running the echo.
>   while :; do; echo ${|REPLY=x;break}; done

Indeed, good idea.




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