Path: csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: "" 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: References: <20200420051508.GA2359844@zx2c4.com> <7496b183-2db3-6c03-6074-928adcd08f45@case.edu> <9b358a76-4867-41b9-5a3a-c1892c76b8ee@case.edu> <917bf529-d3cb-6783-326b-c7baa7ca9a2e@archlinux.org> 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: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrkedtgddutdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgogfhmphhthietlhhirghsucdlvddtmdenucfjug hrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpedffdcuoehkfhhm sehplhhushhhkhgrvhgrrdhnvghtqeenucggtffrrghtthgvrhhnpeekueekudekvdekgf dvffdvgeegveehgfffhfeuuddtleehtdehvdekkeduudevkeenucfkphepudelfedrudef kedrvddukedrudeltdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehkfhhmsehplhhushhhkhgrvhgrrdhnvght X-ME-Proxy: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <20200420051508.GA2359844@zx2c4.com> <7496b183-2db3-6c03-6074-928adcd08f45@case.edu> <9b358a76-4867-41b9-5a3a-c1892c76b8ee@case.edu> <917bf529-d3cb-6783-326b-c7baa7ca9a2e@archlinux.org> Xref: csiph.com gnu.bash.bug:16722 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