Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Nofork ${{var}...} edge cases
- X-seq: zsh-workers 52837
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Oliver Kiddle <opk@xxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Nofork ${{var}...} edge cases
- Date: Wed, 27 Mar 2024 18:00:02 -0700
- Archived-at: <https://zsh.org/workers/52837>
- In-reply-to: <42966-1711578160.323146@w_2U.aZv1.yyMw>
- List-id: <zsh-workers.zsh.org>
- References: <CAH+w=7YHZspc2JVBxkkYO69Cr9x__s-m4UQqRUfOetZYssUqnw@mail.gmail.com> <42966-1711578160.323146@w_2U.aZv1.yyMw>
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