Bash/Shell Scripting Best Practices Rule
When generating Bash/shell scripts for automation:
#!/bin/bash
or #!/usr/bin/env bash
).set -e
(exit immediately if a command exits with a non-zero status), set -u
(treat unset variables as an error), and set -o pipefail
(cause a pipeline to return the exit status of the last command that exited with a non-zero status)."$MY_VAR"
) to prevent word splitting and globbing issues. Use ${VAR:-default}
for default values.