On 8/6/20 12:36 PM, k...@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