3 ms·
I also include set -o pipefail (exit if ANY command in a pipeline fails). Had to get bitten and waste an hour before that became a habit. set -e and set -o pi
by cellularmitosis 12y ago
I also include set -o pipefail (exit if ANY command in a pipeline fails). Had to get bitten and waste an hour before that became a habit.
set -e and set -o pipefail really should have been the default, rather than an opt-in.
- nwalfield 12y agoset -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).