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

Re: Suggested changes to Etc/FAQ



About that:

In cmd1 && cmd2 &, only cmd2 instead of the whole expression
is run in the background in zsh. The manual implies this is
a bug. Use { cmd1 && cmd2 } & as a workaround.

And in particular the "The manual implies this is a bug".

That section was added to the FAQ in October 1997. At the time, the manual had:

 If a sublist is terminated
by a `tt(&)', `tt(&|)', or `tt(&!)',
the shell executes it in the background, and
does not wait for it to finish.

But that was later (2000: https://github.com/zsh-users/zsh/commit/ed8b82b9b1bf74392caf4f4683f367bc4cbbd193#diff-6a204419ff23048734de2793d1072ec031dcdcd08aeb14cf75c14ec953835bddL68)
changed to what we have today:

If a sublist is terminated by
a '&', '&|', or '&!', the shell executes the last pipeline in it in the
background, and does not wait for it to finish (note the difference from
other shells which execute the whole sublist in the background)

So that's no longer considered as a bug but works as documented.

So that "The manual implies this is a bug" should be removed I'd think or maybe replaced by something that notes that it was not originally intentional.

{ cmd1 && cmd2 } & might be better as (cmd1 && cmd2) & so it's portable to
other shells and makes it more evident that that runs in a subshell.

--
Stephane




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