Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Suggested changes to Etc/FAQ
- X-seq: zsh-workers 52298
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Suggested changes to Etc/FAQ
- Date: Mon, 13 Nov 2023 07:13:38 +0000
- Archived-at: <https://zsh.org/workers/52298>
- In-reply-to: <CAH+w=7YxP-5fZEdsBEvJXC9X1FVOv=v1z88MC2D1G5xDJQh0aA@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAH+w=7ZOc-yXfGyu9K1Bj0k-o0T_Z3ftsq8pxpu8m3HD3t7Bew@mail.gmail.com> <f8bb79a00979fa637feb4666da703888@chazelas.org> <CAH+w=7YxP-5fZEdsBEvJXC9X1FVOv=v1z88MC2D1G5xDJQh0aA@mail.gmail.com>
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