Find the exit status of programs in a pipeline:
How to find the exit status of foo, rather than bar?
foo | bar
Here's how:
echo ${PIPESTATUS[0]}
Here's how you would get the exit status of both programs:
foo | bar echo ${PIPESTATUS[0]} ${PIPESTATUS[1]} # prints foo exit status followed by bar exit status