Back to all reviewers

Standardize shell flags

chef/chef
Based on 3 comments
Shell

Always use `set -eou pipefail` at the beginning of shell scripts to ensure consistent error handling and behavior across the codebase. This combination provides important safety guarantees:

Code Style Shell

Reviewer Prompt

Always use set -eou pipefail at the beginning of shell scripts to ensure consistent error handling and behavior across the codebase. This combination provides important safety guarantees:

  • -e: Exit immediately if any command exits with non-zero status
  • -o: Error on undefined variables instead of treating them as empty
  • -u: Treat unset variables as an error
  • pipefail: Return value of a pipeline is the status of the last command to exit with non-zero status

Example:

# Incorrect
set -eu -o pipefail
# or 
set -evx

# Correct
set -eou pipefail

This standard helps prevent subtle bugs caused by unhandled errors or undefined variables and makes scripts more robust and predictable.

3
Comments Analyzed
Shell
Primary Language
Code Style
Category

Source Discussions