What is the meaning of set -o pipefail in Bash Script?

Viewed 23626

What is the meaning of set -o pipefail in the beginning of the shell script ?

1 Answers

man bash says

pipefail

If set, the return value of a pipeline is the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands in the pipeline exit successfully. This option is disabled by default.

Where "pipeline" is

command1 | command2 | command3

Without pipefail, the return value of a pipeline is the exit status of the last command.

Related