Path: csiph.com!news.mixmin.net!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Webstrand Newsgroups: gnu.bash.bug Subject: Bug when using pipefail and lastpipe together in bash-4.4 Date: Tue, 8 Oct 2019 09:43:23 -0400 Lines: 69 Approved: bug-bash@gnu.org Message-ID: References: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="000000000000d3d4c70594665a3f" X-Trace: usenet.stanford.edu 1570545551 3692 209.51.188.17 (8 Oct 2019 14:39:11 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=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=g1Z+NIuEdQZJyYIe+h2SHw8jfM1TEdaEUtElBg5foPk=; b=QgMF3tpI8nZ7RPOx00A8xnpqTF2hJF/jB6eRZ0dBP0lwyJUFjM4Hbg67ikJyUbRCRn hp+bkH14BoistDZ+ja70A5CV/H10pdKj1pbZnO00etl1YxyZXKLxgrrQk3vltc2lvNZJ FojPlAdwx8MxVGn+CvAT6pK+uEpi82HSkE73wMZcFRiLp3S2IXSeYBpFwDmOcFYhTqPh Rz6/F6j1x4/OpcjIx6Dnvhh2BN29+FA7hi9IXJs0JDm4xECPaOiGnZLG+o1JairmzqKL 2LQVem7qRMeyriqh3vP3KZaNelx1BBdwnQuA5OcXJTgxs81f1XSdenQ7OVfhmTz07BrX iBgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=g1Z+NIuEdQZJyYIe+h2SHw8jfM1TEdaEUtElBg5foPk=; b=Ts/AdlpFeevOBwSuda3YEf+/ZSbbz/Tkis5f0dhKrXvAEr+ALlwoLc8EAi/4aXVwuH chk/HBTqu/zkqRmuRQDDVg67MtgkLKXZXILmTFNkheZ8pXXhGsnjHWTTRabo2WvNJiUh Fj9mdwVOgzYb7ZtUT5meazH7z2pn3Nrs4I2+IXWxm02xhyTdFAmGFIFJSPu3G1bp2wmf qV0Cglge0FA8lokAQYjb6hE8CjCMGqtYZE2ZmEwcsr0UnSaoyrYQJlGk1VRMi+VZnzrY OEsblu1ls+lHUllbuRlmQsc1Tq/I2ND49ipEd62uPT0xDFxCYJkxOncxldBZJr3DgRWe Whqg== X-Gm-Message-State: APjAAAUAEte2exEmnVYz4ElN+jf3DpbOa8MNbeASSixYgZnqO+gOkOMG oRbZwd2CsWjxUAQ2S6W1kWPsrbn9xHD/c9Y33L//ENs4 X-Google-Smtp-Source: APXvYqyxPbBFGHCTVEC5nsCwBO8dRAmkYI8Y/TzgxxbV1fANBehfA1Z+1O9TvfhZ3tIzGtwhNeX6ZtyfUBnWLNPCdLM= X-Received: by 2002:aca:5294:: with SMTP id g142mr4003855oib.44.1570542214948; Tue, 08 Oct 2019 06:43:34 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::241 X-Mailman-Approved-At: Tue, 08 Oct 2019 10:39:08 -0400 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: Xref: csiph.com gnu.bash.bug:15485 --000000000000d3d4c70594665a3f Content-Type: text/plain; charset="UTF-8" When running the following script under bash-4.4.0 to bash-4.4.23 it seems to fail erroneously on read. set -x set -o pipefail shopt -s lastpipe main() { # Any input piped into while such that the condition # succeeds at least once. echo "x" | while read; do echo | read # anything piped to read sleep 0 # any non-builtin done } main || echo "main failed" This produces the xtrace: + set -o pipefail + shopt -s lastpipe + main + read + echo x + read + echo + sleep 0 + read + echo 'main failed' main failed Under bash-4.3 and bash-5.0 the script does not output "main failed", as expected. I'm not sure if this is a known bug. One user on IRC reported finding the same issue on debian stretch, but another could not reproduce the issue for bash-4.4.12. I have bisected the history of the devel git branch and found that the commit: 85ec0778f9d778e1820fb8c0e3e996f2d1103b45 commit bash-20150417 snapshot introduces the issue. Applying the attached patch to a bash-4.4.23 source tree produces an interpreter which does not output "main failed" when running the aforementioned script. --000000000000d3d4c70594665a3f Content-Type: text/x-patch; charset="US-ASCII"; name="Revert-job-tracking-changes.patch" Content-Disposition: attachment; filename="Revert-job-tracking-changes.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_k1hw1gw30 ZGlmZiAtLWdpdCBhL2pvYnMuYyBiL2pvYnMuYwppbmRleCBkNjliOGQ4ZC4uZWMwMTRkMWYgMTAw NjQ0Ci0tLSBhL2pvYnMuYworKysgYi9qb2JzLmMKQEAgLTEwNDMsOSArMTA0MywxMCBAQCBkZWxl dGVfam9iIChqb2JfaW5kZXgsIGRmbGFncykKICAgaWYgKHRlbXAgPT0gMCkKICAgICByZXR1cm47 CiAKLSAgaWYgKChkZmxhZ3MgJiBERUxfTk9CR1BJRCkgPT0gMCAmJiAodGVtcC0+ZmxhZ3MgJiAo Sl9BU1lOQ3xKX0ZPUkVHUk9VTkQpKSA9PSBKX0FTWU5DKQorICBpZiAoKGRmbGFncyAmIERFTF9O T0JHUElEKSA9PSAwKQogICAgIHsKICAgICAgIHByb2MgPSBmaW5kX2xhc3RfcHJvYyAoam9iX2lu ZGV4LCAwKTsKKyAgICAgIC8qIENvdWxkIGRvIHRoaXMganVzdCBmb3IgSl9BU1lOQyBqb2JzLCBi dXQgd2Ugc2F2ZSBhbGwuICovCiAgICAgICBpZiAocHJvYykKIAliZ3BfYWRkIChwcm9jLT5waWQs IHByb2Nlc3NfZXhpdF9zdGF0dXMgKHByb2MtPnN0YXR1cykpOwogICAgIH0K --000000000000d3d4c70594665a3f--