bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: waiting for process substitutions


From: Zachary Santer
Subject: Re: waiting for process substitutions
Date: Tue, 2 Jul 2024 21:59:50 -0400

On Tue, Jul 2, 2024 at 4:56 PM Mark March <m_a_r_c_h@yahoo.com> wrote:
>
> lastpipe takes effect only if job control is off. From the man page:
>
>     lastpipe
>                       If set, and job control is not active,  the  shell....
>
> With laspipe on and job control off, 'wait' appears to wait for all process 
> substitutions:
>
> set +m
> shopt -s lastpipe
> echo $'foo\nbar' | tee >(echo first ; exit 1) >(wc ; sleep 10 ; echo wc) 
> >(tail -n 1; echo tail)
> wait
>
> blocks for 10s under Bash 5.2.21.
>
> Likely just a documentation bug.

I didn't have lastpipe enabled in my initial repeat-by script. Now
that this one has that as an option, I'm not seeing a difference in
behavior between having it enabled or not.

I *am* seeing a difference between having lastpipe enabled (and job
control off) or not when running your example in the interactive
shell, though:
SECONDS=0; echo $'foo\nbar' | tee >(echo first ; exit 1) >(wc ; sleep
10 ; echo wc) >(tail -n 1; echo tail); wait; printf '%s\n'
"SECONDS=${SECONDS}"

With lastpipe disabled, wait exits immediately. With lastpipe enabled,
it does seem to wait for everything. I'm going to go with the change
in behavior here being unintended, actually. Besides having different
set and shopt options on or off by default, running things in the
interactive shell versus in a script doesn't tend to differ much.
Could be an interaction with some other set or shopt option whose
setting differs between a script and the interactive shell, I guess.

Attachment: procsub-wait
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]