SECURITY WARNING: Never run commands you don't understand. Always review code before execution. Use at your own risk.
Shell 13 errors

Shell & Bash Errors

Command not found, permissions, quoting, expansion and Makefile syntax.

Understanding Shell errors

Shell errors are usually about PATH, permissions, or quoting and expansion. The quoting class is the most damaging because it fails silently: an unquoted variable containing a space becomes two arguments, and an empty one disappears entirely. Running shellcheck over any script longer than a few lines catches most of these before they run.

How to debug Shell errors

  1. Trace execution with bash -x script.sh to see each command after expansion. This makes quoting bugs immediately visible.
  2. Start every script with set -euo pipefail so failures stop the script instead of cascading.
  3. Quote every variable expansion: "$var", "${arr[@]}". This single habit prevents the majority of shell bugs.
  4. Use command -v foo to check whether something is on PATH, and echo "$PATH" to see what the shell is actually searching.
  5. In Makefiles, recipe lines must begin with a real tab character. "missing separator" always means spaces were used instead.

Tools worth reaching for

  • shellcheck
  • bash -x
  • set -euo pipefail
  • command -v
  • cat -A (to reveal tabs)

All 13 Shell errors

Other categories