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

Re: Bug with assignments in some commands



> On 18 January 2021 at 15:32 Patrick Reader <zsh578@xxxxxxxxxx> wrote:
> I believe I have found a bug: in arithmetic $(( )) or $[ ] and variable 
> expansions ${ } in some forms of command (pipelines, command 
> substitutions, and inside here-documents and here-strings are the cases 
> I know of so far), assignments to variables do not persist outside the 
> command, almost as if it were in a subshell.

They *are* in a subshell.  That's just how the shell works.

The only difference between zsh and other shells is that some other shells
run the left hand of a pipeline rather than the right hand of a pipeline
in the current shell (if it's shell code, of course), but that's not
something you can rely on.  There is a patch floating around for
a compatibility mode, but in native zsh mode running the right hand
of a pipeline in the current shell, and hence the other parts in
subshells, is a feature.

pws




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