Path: csiph.com!fu-berlin.de!usenet.stanford.edu!not-for-mail From: =?UTF-8?B?T8SfdXo=?= Newsgroups: gnu.bash.bug Subject: Re: process substitution error handling Date: Thu, 6 Aug 2020 14:15:43 +0300 Lines: 51 Approved: bug-bash@gnu.org Message-ID: References: <20200420051508.GA2359844@zx2c4.com> <7496b183-2db3-6c03-6074-928adcd08f45@case.edu> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: usenet.stanford.edu 1596712551 28187 209.51.188.17 (6 Aug 2020 11:15:51 GMT) X-Complaints-To: action@cs.stanford.edu Cc: "bug-bash@gnu.org" To: "Jason A. Donenfeld" Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Pnmu3hH3KpK0B/YuxarjLxiJHS79Zt8/kq6uq5aB4f0=; b=EmU+K6ybvhmpiMnKBklxbmONdhSkxLIXzCBI8KelzonO3kojrSSTSAmsoAWgWI0JZy BzcwZS2vNSkJ41h8qv5e4y1pKndWSPf5zzZ1nxVOBsmF8evabC1fMmwiWvLartpuConA U++GUKoMbVNVnk2jSm7+8pjVg4p0OX63Krc58uHXXfxL2JKqtCutIyKbjy4V3Ts9XvR2 wzVIKRV1n5ze6M4CWCgmT8iuasZWCRXRijF2D1naOOWIH4WZ6hBpjykCLLHddJgdSo2B 5wEl1CWQfS6O2uztj/ciStwfrDGC+t+Q+LmXY0bDZjrgUT0LjwnfDkmwO/kX0qE/qjBG LEiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Pnmu3hH3KpK0B/YuxarjLxiJHS79Zt8/kq6uq5aB4f0=; b=uC8lhQi9o8sDXJuYoTOliUV43eSQ0j4z1XVGECWIR8LkAXqMoH+x9pW9B4G938PUcd qHmkbDgGceaiJ7FZxsJFiG2RXnd0U5gr8jXMJjC6RkSEz489Fd9O5v9qDLk0OuR9Nuf9 8GD3+plxccqFBK50gikPqQAWmVRrxk7oGL/yrsQzg04rEop0oblwuCt54YtIiF6aIoMZ g0LtMBcMAgPBic8KkJqDzWdhN4FGDnDAFQDIk8ANkbUxL8kDsqHRkRR14ANbOVFvz70/ 4n9i9SZDCwDlNJTJ+OXZfbEHPyoROvETDcGt/SuruJEodGYsuFjZwKZlujXkgKYWwJkt Jqxg== X-Gm-Message-State: AOAM530muf2RURPqfCYdJFG0418qeZ6ucRW64XdsZOCG7OrWY6E0dvBN D96DKTdz+ovbRrZHgAcwXQkqFRTffoE6MON6fBA5AYzW X-Google-Smtp-Source: ABdhPJyAGx/+RzLpLafq3m5eU7gT8WPVX8mGvB+3k69GASPB0fTzJwODRgF+vUg1fIeebopZz55eVzFNzO+8EFRxEXA= X-Received: by 2002:ac8:306a:: with SMTP id g39mr8237964qte.259.1596712543917; Thu, 06 Aug 2020 04:15:43 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::833; envelope-from=oguzismailuysal@gmail.com; helo=mail-qt1-x833.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 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> Xref: csiph.com gnu.bash.bug:16702 6 A=C4=9Fustos 2020 Per=C5=9Fembe tarihinde Jason A. Donenfeld yazd=C4=B1: > Hi, > > It may be a surprise to some that this code here winds up printing > "done", always: > > $ cat a.bash > set -e -o pipefail > while read -r line; do > echo "$line" > done < <(echo 1; sleep 1; echo 2; sleep 1; false; exit 1) > sleep 1 > echo done > > $ bash a.bash > 1 > 2 > done > > The reason for this is that process substitution right now does not > propagate errors. It's sort of possible to almost make this better > with `|| kill $$` or some variant, and trap handlers, but that's very > clunky and fraught with its own problems. > > Therefore, I propose a `set -o substfail` option for the upcoming bash > 5.1, which would cause process substitution to propagate its errors > upwards, even if done asynchronously. > > set -e o substfail : <(sleep 10; exit 1) foo Say that `foo' is a command that takes longer than ten seconds to complete, how would you expect the shell to behave here? Should it interrupt `foo' or wait for its termination and exit then? Or do something else? > Chet - thoughts? > > It'd certainly make a lot of my scripts more reliable. > > Jason > > --=20 O=C4=9Fuz