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

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



On Thu, Mar 28, 2024 at 2:33 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Wed, Mar 27, 2024 at 6:21 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > > Hrm, unfortunately that gets a bit dicey, because ${ ... } relies on
> > > having the magic local $REPLY as a place to stash the captured stdout
> >
> > Oh, no, it doesn't:  I confused myself because some the tests in D10 do so.
>
> Please ignore that.  Both the tests AND the implementation do this.  Ugh.

This just came up on IRC, and I'm not sure what the currently expected
result is here, and I couldn't find any test coverage for this either:
% REPLY=before; echo $REPLY ${ echo 1} ${| REPLY=2} $REPLY
before 1 2 1

I find it very surprising that REPLY is overwritten by ${ echo 1}
here, and I couldn't find anything in the man page about it other than
a vague statement about ${ foo} saying "Like ${|...}, the command
executes in the current shell context with function local behaviors",
but I don't think this would imply that REPLY gets overwritten, right?
And it's also surprising since ${| foo} goes to such lengths to
explicitly not overwrite it.

-- 
Mikael Magnusson




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