zsh-workers
 help / color / mirror / code / Atom feed
* Effect of different sublist execution?
@ 2023-03-14 11:06 Sebastian Gniazdowski
  2023-03-14 11:15 ` Roman Perepelitsa
  0 siblings, 1 reply; 2+ messages in thread
From: Sebastian Gniazdowski @ 2023-03-14 11:06 UTC (permalink / raw)
  To: Zsh hackers list

Doc say:

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

I wonder about presenting this via some real effect. How to show that
only the last pipeline is running in background (like the doc say)
when sublist/pipeline is ended via &? I'm looking for a snippet that
will behave differently for the two cases: sublist &-ended and ;-ended
.

-- 
Best regards,
Sebastian Gniazdowski


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Effect of different sublist execution?
  2023-03-14 11:06 Effect of different sublist execution? Sebastian Gniazdowski
@ 2023-03-14 11:15 ` Roman Perepelitsa
  0 siblings, 0 replies; 2+ messages in thread
From: Roman Perepelitsa @ 2023-03-14 11:15 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: Zsh hackers list

On Tue, Mar 14, 2023 at 12:07 PM Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
>
> Doc say:
>
> If a sublist is terminated by a `&',
> `&|', or `&!', the shell executes the last pipeline in it in the  back‐
> ground,  and  does  not wait for it to finish (note the difference from
> other shells which execute the whole sublist  in  the  background).
>
> I wonder about presenting this via some real effect. How to show that
> only the last pipeline is running in background (like the doc say)
> when sublist/pipeline is ended via &? I'm looking for a snippet that
> will behave differently for the two cases: sublist &-ended and ;-ended

You can try this:

    sleep 5 && true &

In zsh this code will block for 5 while in bash it'll execute
instantly. You can confirm that zsh executes the first part of the
sublist without forking with this code:

    % zmodload zsh/system
    % print $sysparams[pid]
    4268
    % print $sysparams[pid] && true &
    4268

Roman.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-14 11:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-14 11:06 Effect of different sublist execution? Sebastian Gniazdowski
2023-03-14 11:15 ` Roman Perepelitsa

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).