Originally, I had:
$ cat /etc/passwd | head -n 1
root:x:0:0:root:/root:/bin/bash
$ echo ${PIPESTATUS[@]}
0 0
Ie, 'cat' exits success.
That is actually not true. that specific example of 'cat' would never get a broken pipe signal as it would read all of /etc/passwd, write all of /etc/passwd , head would read into buf, split lines, exit.
Originally, I had: 0:0:root: /root:/ bin/bash
$ cat /etc/passwd | head -n 1
root:x:
$ echo ${PIPESTATUS[@]}
0 0
Ie, 'cat' exits success.
That is actually not true. that specific example of 'cat' would never get a broken pipe signal as it would read all of /etc/passwd, write all of /etc/passwd , head would read into buf, split lines, exit.
Better example:
$ cat /dev/zero | head -c 1 ; echo ${PIPESTATUS[@]}
141 0
Note that 141-128=13 and SIGPIPE==13