4 ms·
set -o pipefail makes common idioms a pain. Consider using head, which simply exits after it has read a few lines. In this case, the input process gets a SIGP
by nwalfield 12y ago
set -o pipefail makes common idioms a pain. Consider using head, which simply exits after it has read a few lines. In this case, the input process gets a SIGPIPE and exits with a non-zero exit code:
Consider /tmp/test.sh:
set -o pipefail
yes foo | head
$ bash /tmp/test.sh >/dev/null
$ echo $?
141
- pixelbeat 12y agoThat's a bug IMHO which I reported at http://lists.gnu.org/archive/html/bug-bash/2015-02/msg00052.html http://lists.gnu.org/archive/html/bug-bash/2015-02/msg00052.... I've collated other mishandling of closed pipes at: http://www.pixelbeat.org/programming/sigpipe_handling.html http://www.pixelbeat.org/programming/sigpipe_handling.html
- quotemstr 12y agoFor a while now, I've thought we should change SIGPIPE's SIG_DFL action to _exit(0).