Bash Version: 3.1
Patch Level: 17
Release Status: release
Description:
When a trap is caught while a pipe is running, the $PIPESTATUS
array contains the exit values of the trap.
$? seems to work fine (it's 1 from the pipe in my example),
but the PIPESTATUS array not.
Repeat-By:
trap 'true' USR1
echo "PID: $$"
# Send USR1 to the script from another shell while sleep is running
false | sleep 10 | false
echo "\$?: $? | \${PIPESTATUS[@]}: ${PIPESTATUS[@]}"