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

Re: [PATCH v2] exec: run final pipeline command in a subshell in sh mode



On 6/5/20, brian m. carlson <sandals@xxxxxxxxxxxxxxxxxxxx> wrote:
> zsh typically runs the final command in a pipeline in the main shell
> instead of a subshell.  However, POSIX requires that all commands in a
> pipeline run in a subshell, but permits zsh's behavior as an extension.

What POSIX actually says is:
"each command of a multi-command pipeline is in a subshell
environment; as an extension, however, any or all commands in a
pipeline may be executed in the current environment"
Ie, it does not say "shall", so it doesn't require a subshell all, in
fact it explicitly does permit not using one as you also say. The
patch is possibly useful (seems unlikely to me), but to say it is
required by POSIX is not true. If someone depends on every command in
a pipeline being a subshell, they should fix their code, for example
by adding ( ) around it (the command(s) or the whole pipeline).

-- 
Mikael Magnusson



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