484160a9cf
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 works similarly to the option in bash, ksh93 and mksh. Like ksh93 and unlike bash and mksh, the state of the option is saved when 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 required for a proper exit status for pipelines containing commands such as head that may terminate successfully without reading all input. This can be something like ( cmd1 r=$? if [ "$r" -gt 128 ] && [ "$(kill -l "$r")" = PIPE ]; then exit 0 else exit "$r" fi ) | head PR: 224270 Relnotes: yes |
||
---|---|---|
.. | ||
bg1.0 | ||
bg2.0 | ||
bg3.0 | ||
bg4.0 | ||
bg5.0 | ||
bg6.0 | ||
bg6.0.stdout | ||
bg7.0 | ||
bg8.0 | ||
bg9.0 | ||
bg10.0 | ||
bg10.0.stdout | ||
env1.0 | ||
fork1.0 | ||
fork2.0 | ||
fork3.0 | ||
func1.0 | ||
func2.0 | ||
func3.0 | ||
hash1.0 | ||
int-cmd1.0 | ||
killed1.0 | ||
killed2.0 | ||
Makefile | ||
Makefile.depend | ||
not1.0 | ||
not2.0 | ||
path1.0 | ||
pipefail1.0 | ||
pipefail2.42 | ||
pipefail3.42 | ||
pipefail4.42 | ||
pipefail5.42 | ||
pipefail6.42 | ||
pipefail7.0 | ||
redir1.0 | ||
redir2.0 | ||
redir3.0 | ||
redir4.0 | ||
redir5.0 | ||
redir6.0 | ||
redir7.0 | ||
set-C1.0 | ||
set-n1.0 | ||
set-n2.0 | ||
set-n3.0 | ||
set-n4.0 | ||
set-x1.0 | ||
set-x2.0 | ||
set-x3.0 | ||
set-x4.0 | ||
shellproc1.0 | ||
subshell1.0 | ||
subshell1.0.stdout | ||
subshell2.0 | ||
subshell3.0 | ||
subshell4.0 | ||
unknown1.0 | ||
var-assign1.0 |