Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15485

Bug when using pipefail and lastpipe together in bash-4.4

Path csiph.com!news.mixmin.net!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Webstrand <webstrand@gmail.com>
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 <mailman.1368.1570545550.2651.bug-bash@gnu.org> (permalink)
References <CACm1TQebG+cnYuxqFSU7uu29XczQdRiO_M1RW-ne3isZkwbwsg@mail.gmail.com>
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 <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 <CACm1TQebG+cnYuxqFSU7uu29XczQdRiO_M1RW-ne3isZkwbwsg@mail.gmail.com>
Xref csiph.com gnu.bash.bug:15485

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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.

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Bug when using pipefail and lastpipe together in bash-4.4 Webstrand <webstrand@gmail.com> - 2019-10-08 09:43 -0400

csiph-web