[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: process substitution error handling
From: |
Eli Schwartz |
Subject: |
Re: process substitution error handling |
Date: |
Thu, 6 Aug 2020 13:09:23 -0400 |
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
signature.asc
Description: OpenPGP digital signature
- Re: process substitution error handling, (continued)
Re: process substitution error handling, Chet Ramey, 2020/08/06
- Re: process substitution error handling, Jason A. Donenfeld, 2020/08/06
- Re: process substitution error handling, Chet Ramey, 2020/08/06
- Re: process substitution error handling, Chet Ramey, 2020/08/06
- Re: process substitution error handling, Jason A. Donenfeld, 2020/08/06
- Re: process substitution error handling, Chet Ramey, 2020/08/06
- Re: process substitution error handling, Eli Schwartz, 2020/08/06
- Re: process substitution error handling, , 2020/08/06
- Re: process substitution error handling,
Eli Schwartz <=