Variables and conditions
Shell scripts gain power from strict variable handling and predictable control flow.
Recommendations
- Use
set -euo pipefailfor safer execution. - Quote variables unless you explicitly need word splitting.
- Prefer
[[ ... ]]over[ ... ]for conditionals.
Example
bash
set -euo pipefail
if [[ -z "${LOG_PATH:-}" ]]; then
echo "LOG_PATH is required" >&2
exit 1
fi