Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

bash

shell

sh

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

like image 615
rɑːdʒɑ Avatar asked Dec 14 '22 07:12

rɑːdʒɑ


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.

like image 72
choroba Avatar answered Dec 27 '22 20:12

choroba