Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Mar 2019 22:34:59 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 224270] Get exit status of process that's piped to another: set -o pipefail is missing for /bin/sh
Message-ID:  <bug-224270-227-XBknVv0v3Z@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-224270-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-224270-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D224270

--- Comment #17 from commit-hook@freebsd.org ---
A commit references this bug:

Author: jilles
Date: Tue Mar 26 22:34:10 UTC 2019
New revision: 345561
URL: https://svnweb.freebsd.org/changeset/base/345561

Log:
  MFC r344502: sh: Add set -o pipefail

  The pipefail option allows checking the exit status of all commands in a
  pipeline more easily, at a limited cost of complexity in sh itself. It wo=
rks
  similarly to the option in bash, ksh93 and mksh.

  Like ksh93 and unlike bash and mksh, the state of the option is saved whe=
n a
  pipeline is started. Therefore, even in the case of commands like
    A | B &
  a later change of the option does not change the exit status, the same way
    (A | B) &
  works.

  Since SIGPIPE is not handled specially, more work in the script is requir=
ed
  for a proper exit status for pipelines containing commands such as head t=
hat
  may terminate successfully without reading all input. This can be somethi=
ng
  like

  (
        cmd1
        r=3D$?
        if [ "$r" -gt 128 ] && [ "$(kill -l "$r")" =3D PIPE ]; then
                exit 0
        else
                exit "$r"
        fi
  ) | head

  PR:           224270
  Relnotes:     yes

Changes:
_U  stable/11/
  stable/11/bin/sh/jobs.c
  stable/11/bin/sh/options.h
  stable/11/bin/sh/sh.1
  stable/11/bin/sh/tests/execution/Makefile
  stable/11/bin/sh/tests/execution/pipefail1.0
  stable/11/bin/sh/tests/execution/pipefail2.42
  stable/11/bin/sh/tests/execution/pipefail3.42
  stable/11/bin/sh/tests/execution/pipefail4.42
  stable/11/bin/sh/tests/execution/pipefail5.42
  stable/11/bin/sh/tests/execution/pipefail6.42
  stable/11/bin/sh/tests/execution/pipefail7.0

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-224270-227-XBknVv0v3Z>