mikepapadim
mikepapadim

Reputation: 453

Difference of -e, -u and -o pipefail in bash exit status

Being trying to properly guard for non-zero exits on a bash script.

What is the difference between -e, -u and -o pipefail?

-o pipefail is not sufficient to exit with an error code?

Upvotes: 5

Views: 2857

Answers (1)

Karl-Marx
Karl-Marx

Reputation: 546

set -e: Exit immediately if a command exits with a non-zero status.

set -u: If you try to access an undefined variable, that is an error.

set -o pipefail: If any command in a pipeline returns a non-zero exit code, the return code of the entire pipeline is the exit code of the last failed command.

Upvotes: 8

Related Questions