Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16723

Re: process substitution error handling

From Eli Schwartz <eschwartz@archlinux.org>
Newsgroups gnu.bash.bug
Subject Re: process substitution error handling
Date 2020-08-06 13:09 -0400
Message-ID <mailman.1037.1596733788.2739.bug-bash@gnu.org> (permalink)
References (5 earlier) <9b358a76-4867-41b9-5a3a-c1892c76b8ee@case.edu> <CAHmME9qHEtsri_jYdqppSXwYFLH3Os06xS7wsM00z2dNgHgwyg@mail.gmail.com> <917bf529-d3cb-6783-326b-c7baa7ca9a2e@archlinux.org> <c87777d1-188f-8353-e646-24c64c243710@plushkava.net> <3eb8128c-6f15-473e-447a-5058aef52b9b@archlinux.org>

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On 8/6/20 12:36 PM, kfm@plushkava.net wrote:
> On 06/08/2020 17:21, Eli Schwartz wrote:
>> On 8/6/20 11:31 AM, Jason A. Donenfeld wrote:
>>> That doesn't always work:
>>>
>>> set -e
>>> while read -r line; do
>>>         echo "$line" &
>>> done < <(echo 1; sleep 1; echo 2; sleep 1; exit 77)
>>> sleep 1
>>> wait $!
>>> echo done
> 
> I wonder why wait $! doesn't do the job here.

Because `echo "$line" &` sets a new value for $! after the <() did.

More to the point, you want to wait $! *before* running any commands in
the while loop, because if the <() failed, it might not be a good idea
to run those commands.

-- 
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: process substitution error handling Eli Schwartz <eschwartz@archlinux.org> - 2020-08-06 13:09 -0400

csiph-web