32

What is the meaning of the below command? I am new in shell scripting.

set -e -o pipefail
muru
  • 69,900
  • 13
  • 192
  • 292
Dipak Pawar
  • 439
  • 1
  • 4
  • 3

1 Answers1

38

End the script immediately if any command or pipe exits with a non-zero status.

I don't usually use these two flags, but if you're just getting started shell scripting, this would be like turning on warnings or strict mode in other languages.

-e

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

-o <option-name>

Sets the <option-name> flag. In this case, it sets the pipefail option.

pipefail

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

eureka
  • 103
  • 3
erwin
  • 1,723
  • 1
  • 9
  • 18