Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Nofork ${{var}...} edge cases
- X-seq: zsh-workers 53711
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Mikael Magnusson <mikachu@xxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Nofork ${{var}...} edge cases
- Date: Sat, 31 May 2025 01:57:39 -0700
- Archived-at: <https://zsh.org/workers/53711>
- In-reply-to: <CAHYJk3S1RG0cOMnGEEG5_RHdGMbhRNPe1GJe3xNsYbTi5M1zMg@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAH+w=7YHZspc2JVBxkkYO69Cr9x__s-m4UQqRUfOetZYssUqnw@mail.gmail.com> <42966-1711578160.323146@w_2U.aZv1.yyMw> <CAH+w=7Y7gD8vKsk-=UEaf4N0j9u+ruNKS8nUZGZNAb23cRGSEQ@mail.gmail.com> <CAH+w=7akD45JDWRdRwrEbO9_2SMYgZYm2ctprx+JVo4F=Pur-Q@mail.gmail.com> <CAH+w=7ZpN6KVEWJGVjA-Yh8zYeQ1kRTxeaY8pZBmquv-XPVtmA@mail.gmail.com> <CAHYJk3S1RG0cOMnGEEG5_RHdGMbhRNPe1GJe3xNsYbTi5M1zMg@mail.gmail.com>
On Sat, May 31, 2025 at 12:21 AM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>
> 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}
Not really obvious but you have to have a space between "1" and "}" --
spaces inside BOTH braces, not just the left one. Without the final
space, this is being interpreted as
${{} echo 1}
which defaults to using $REPLY in the scope of the caller, just as if you wrote
${{REPLY} echo 1}.
REPLY is chosen there because ${| echo 1} uses REPLY.
${{} ...} is permitted because ${} is permitted. Overlooked when
writing the doc, sorry.
${ ... } (with the spaces on both ends) actually uses an undocumented
read-only local ${.zsh.cmdsubst}.
It might be possible to make it a bad substitution to skip the final space.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author