Can someone explain why I get exit code 141 from the below?
#!/usr/bin/bash
set -o pipefail
zfs list | grep tank
echo a ${PIPESTATUS[@]}
zfs list | grep -q tank
echo b ${PIPESTATUS[@]}
cat /etc/passwd | grep -q root
echo c ${PIPESTATUS[@]}
I get
...
a 0 0
b 141 0
c 0 0
From my understanding exit code 141 is a failure, but the line above gives zero, so it should be success, I would say.
SIGPIPE
is signal 13, 141 - 128 = 13 indicates your program was ended by aSIGPIPE
. – Rumilly