Safe defaults for a shell script

Back to list2025-07-27
You

What should be at the top of every bash script?

ChatGPT

Three lines that turn silent breakage into loud breakage:

#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'

-e stops on error, -u rejects unset variables, pipefail makes a failing command inside a pipe fail the whole pipe. The last one is what catches curl ... | tar x quietly producing nothing.