I am using following options
set -o pipefail
set -e
In bash script to stop execution on error. I have ~100 lines of script executing and I don’t want to check return code of every line in the script.
But for one particular command, I want to ignore the error. How can I do that?
The solution:
Example:
threewill be never printed.Also, I want to add that when
pipefailis on,it is enough for shell to think that the entire pipe has non-zero exit code
when one of commands in the pipe has non-zero exit code (with
pipefailoff it must the last one).