I'm currently wondering how to do error handling for chained commands. The following is just an example to easily demonstrate my problem:
cat file | gzip >/tmp/test
If the cat fails (because, for example, the file is missing), gzip is still executing and therefore the last stored exit code in $? is 0. set -e will not help in this case.
I wonder what is the best solution for this?
thanks!
bash error-handling
aurora
source share