Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16722
| Path | csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail |
|---|---|
| From | "" <kfm@plushkava.net> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: process substitution error handling |
| Date | Thu, 6 Aug 2020 17:36:35 +0100 |
| Lines | 45 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.1036.1596731802.2739.bug-bash@gnu.org> (permalink) |
| References | <20200420051508.GA2359844@zx2c4.com> <7496b183-2db3-6c03-6074-928adcd08f45@case.edu> <CAHmME9pzOY_0EJ69y9wt6r-Jh3frZpV8XdFC6zG5EOkZ99h-1A@mail.gmail.com> <ac79e09f-b4e3-5368-87c1-b6e7147809e2@case.edu> <CAHmME9qNjO+LMxB8py2MDpS2Oprv1mRndgfTXQfXNWyHuwzmjg@mail.gmail.com> <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> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | usenet.stanford.edu 1596731803 7503 209.51.188.17 (6 Aug 2020 16:36:43 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| To | bug-bash@gnu.org |
| Envelope-to | bug-bash@gnu.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=plushkava.net; h=subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=u UrDFZa7L1wm9qF/ZPN1dBv8G7ppvoIQHKIhi2Pn9Qk=; b=pNcaT2h9L55eppQ+y KjoUbjGxf9Mg8vyuuGKXHUUl6cu3rbuKUuU2MtSOR9HAWSHRoYdS5S0ofSGjDR8m FRU7MpRlrjCwWkujHccOmMSWvl2nUwCN18HGzVRyqMF0OTsuPyl/jguz+pvBTu+K yGQGgqewyFFeleIb/H7p+NFJjWqXZVxQxhfI7dzvJibNq8b1Qo0uvBhwE8zGMS18 zJFJ5GVkRog0pQId/W2kJQfN/PtTdCsfPmpsmdT8Djku8mngxiduUVDPF16tnWZB ytf92Y9MlvbLTpxIJeyHSoMHmAC+O4S2wo/r2u+dsdPy/i4qw+ujO9pelcOFw91i kmsRg== |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=uUrDFZa7L1wm9qF/ZPN1dBv8G7ppvoIQHKIhi2Pn9 Qk=; b=EwU2DuGMCQehxkdMdzKlkG3E9LJF6YirWrZJxDcjqMVd0zestRLpxu/ra OTij82pctFkYaAvCP42a3cClw8op5PB+PtPxmLlj8YMzro6Ti96nnL29pP5W3arp XzLcETtk3CVj1upsf6lHFD6v+fEe/g4V1vYL+gZlz4fXrw/zukxgRV2TZYTr+wLY IT0jzWvsT/GJYNrBg9HP+pQwHPZpb/dXsT/ter9D8yl6LsG5xhR65jmFwZJ8DLb7 0sdBKV+jYqEBw4q0Uc3eI1n/0rNtT1YEKEHpLaEO9VES08XLv+lj2lO9hPDBcP3t N6faZiMYxJXB+j4Ben7K8RbY+tJlQ== |
| X-ME-Sender | <xms:lTEsXwZDODfiJJZniBxrQFjwmf95yMPEP5jquHd_yQaWusgTAtmQ8w> |
| X-ME-Proxy-Cause | gggruggvucftvghtrhhoucdtuddrgeduiedrkedtgddutdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgogfhmphhthietlhhirghsucdlvddtmdenucfjug hrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpedffdcuoehkfhhm sehplhhushhhkhgrvhgrrdhnvghtqeenucggtffrrghtthgvrhhnpeekueekudekvdekgf dvffdvgeegveehgfffhfeuuddtleehtdehvdekkeduudevkeenucfkphepudelfedrudef kedrvddukedrudeltdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehkfhhmsehplhhushhhkhgrvhgrrdhnvght |
| X-ME-Proxy | <xmx:lTEsX7YJqlSOImAhNlbvCufKexIGvDcv3qKvfGOXLWkKlZNMtCr-VA> <xmx:lTEsX6_-R5ArknKyTIBP8wPVB2sCZQUI63hH8zyC4tKc49XcAK7O4w> <xmx:lTEsX6oWsO3c4SGYy-iM-ZBwWEep_UiFLU3tRtx7T6WwENHHsOR82g> <xmx:lTEsXw5CfxendO5wos6ixlKzk3vrOPbbXjaXavYkKr-p7M61UhAmjg> |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.1.0 |
| In-Reply-To | <917bf529-d3cb-6783-326b-c7baa7ca9a2e@archlinux.org> |
| Content-Language | en-US |
| Received-SPF | pass client-ip=66.111.4.25; envelope-from=kfm@plushkava.net; helo=out1-smtp.messagingengine.com |
| X-detected-operating-system | by eggs.gnu.org: First seen = 2020/08/06 12:36:37 |
| X-ACL-Warn | Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] |
| X-Spam_score_int | -20 |
| X-Spam_score | -2.1 |
| X-Spam_bar | -- |
| X-Spam_report | (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_BLANK_NAME=0.723, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=no autolearn_force=no |
| X-Spam_action | no action |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.23 |
| Precedence | list |
| List-Id | Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org> |
| List-Unsubscribe | <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe> |
| List-Archive | <https://lists.gnu.org/archive/html/bug-bash> |
| List-Post | <mailto:bug-bash@gnu.org> |
| List-Help | <mailto:bug-bash-request@gnu.org?subject=help> |
| List-Subscribe | <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <c87777d1-188f-8353-e646-24c64c243710@plushkava.net> |
| X-Mailman-Original-References | <20200420051508.GA2359844@zx2c4.com> <7496b183-2db3-6c03-6074-928adcd08f45@case.edu> <CAHmME9pzOY_0EJ69y9wt6r-Jh3frZpV8XdFC6zG5EOkZ99h-1A@mail.gmail.com> <ac79e09f-b4e3-5368-87c1-b6e7147809e2@case.edu> <CAHmME9qNjO+LMxB8py2MDpS2Oprv1mRndgfTXQfXNWyHuwzmjg@mail.gmail.com> <9b358a76-4867-41b9-5a3a-c1892c76b8ee@case.edu> <CAHmME9qHEtsri_jYdqppSXwYFLH3Os06xS7wsM00z2dNgHgwyg@mail.gmail.com> <917bf529-d3cb-6783-326b-c7baa7ca9a2e@archlinux.org> |
| Xref | csiph.com gnu.bash.bug:16722 |
Show key headers only | View raw
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.
>
> So instead of your contrived case, write it properly. Check the process
> substitution first, and make sure as a bonus you don't run anything if
> if it failed:
>
> set -e
> mapfile -t lines < <(echo 1; sleep 1; echo 2; sleep 1; exit 77)
> wait $!
>
> for line in "${lines[@]}"; do
> echo "$line" &
> sleep 1
> wait $!
> echo done
As Jason appears set on using "set -e -o pipefail", here is another
approach that may be more to his taste:
set -e -o pipefail
{ echo 1; sleep 1; echo 2; sleep 1; exit 77; } | while read -r line; do
echo "$line" &
done
sleep 1
echo done
Of course, the loop will be executed in a subshell, but that can be
averted by shopt -s lastpipe.
--
Kerin Millar
Back to gnu.bash.bug | Previous | Next | Find similar
Re: process substitution error handling "" <kfm@plushkava.net> - 2020-08-06 17:36 +0100
csiph-web