Path: csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: "Jason A. Donenfeld" Newsgroups: gnu.bash.bug Subject: process substitution error handling Date: Thu, 6 Aug 2020 12:05:49 +0200 Lines: 33 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" X-Trace: usenet.stanford.edu 1596708367 24791 209.51.188.17 (6 Aug 2020 10:06:07 GMT) X-Complaints-To: action@cs.stanford.edu Cc: "Demi M. Obenour" To: Chester Ramey , bug-bash@gnu.org Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=mime-version :references:in-reply-to:from:date:message-id:subject:to:cc :content-type; s=mail; bh=XgJGPCdLNOsAjjBZIkw43EW6JR0=; b=Q5MgDk OegFGzKMcIhKupFj5/taivHve9veDMwGK6odpJdaJ3FtWLEBCQ2afPxU9zfx3qyQ TvQ6dc8CK0MBuxq3sRINw95naa6SLySaZRlgAQnMPyg9L2caGqB84CefHJVKfQuz GEZs3OBP0yT2Q+RId+JG2qZ/nOhozJJUztKXOD3bxnekZP7gvB58XaHZJAr/9PBg +ze/nl6uioeZHSInKjdxUuTB03yjCWX3xnAYmqKNCxy+KOjd7LMFh+8DIby8MtkY pFgQ8F9xXNcTjUqr9vl+bn1OssdCDWeKpYQcYSyh6s+WtB3KP8rDbKrWBm+PClv1 0BQx0pZ1goNownPw== X-Gm-Message-State: AOAM532aXbn1c2PM4f7FmfHrh3kGT62JBa6BXn87yuARgKB0EsgYpaZg Tuf5Ajin4idnYFwyJyiNwXhAEUqEj9YKozNFC5g= X-Google-Smtp-Source: ABdhPJxmKMB1k5xah9jOuV1NwEgsnD5AWjxHppH5JkctDN+7NjuQX6nvI3qaudOX3H6fhoARzjSAndB7W5jkYuA7rdg= X-Received: by 2002:a92:d392:: with SMTP id o18mr10207877ilo.224.1596708361336; Thu, 06 Aug 2020 03:06:01 -0700 (PDT) In-Reply-To: <7496b183-2db3-6c03-6074-928adcd08f45@case.edu> X-Gmail-Original-Message-ID: Received-SPF: pass client-ip=192.95.5.64; envelope-from=Jason@zx2c4.com; helo=mail.zx2c4.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/06 06:06:02 X-ACL-Warn: Detected OS = Linux 3.11 and newer 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham 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> Xref: csiph.com gnu.bash.bug:16701 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. Chet - thoughts? It'd certainly make a lot of my scripts more reliable. Jason