User Tools

Site Tools


bash

This is an old revision of the document!


Bash

Useful Bash code, with no particular order

Add safeguards on every script

At the top of the file, always start your scripts with:

set -euo pipefail
  • -e: The -e option will cause a bash script to exit immediately when a command fails.
  • -o pipefail: This particular option sets the exit code of a pipeline to that of the rightmost command to exit with a non-zero status, or to zero if all commands of the pipeline exit successfully.
  • -u: This option causes the bash shell to treat unset variables as an error and exit immediately.
bash.1673965462.txt.gz · Last modified: 2023/01/17 11:24 by roger