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

Re: Effect of different sublist execution?



On Tue, Mar 14, 2023 at 12:07 PM Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> 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.




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