Lint Shell Scripts with ShellCheck
Static-analyze bash and sh scripts for the quoting bugs, unhandled expansions, and portability traps that cause 3 a.m. incidents.
Run shellcheck deploy.sh to list each problem with an SC-numbered explanation, or shellcheck -s bash -e SC2034 script.sh to target a shell and silence specific codes.
01Command
Command
$ shellcheck deploy.sh02What it does
ShellCheck parses the script the way bash would, then flags patterns with known failure modes: unquoted $VAR, rm -rf $DIR under word splitting, useless cat, and cd without error checking. Each finding has an SC code that links to a detailed wiki page explaining the fix — it teaches while it lints. Exit codes are non-zero when issues exist, so it drops into CI or a git pre-commit hook without adaptation.
03Risk
!Warning: ShellCheck is per-file: it can't see runtime data, so a clean report doesn't prove the script is correct — just that no known bug pattern is present.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- ShellCheck READMEEvidence: Describes shellcheck as a static analysis tool for shell scripts with editor integrations and CI usage.
- shellcheck(1) — Linux man pageEvidence: shellcheck man page: 'ShellCheck - warn about shell script syntax errors, semantic problems' with -s shell and -e exclusion options.
Last verified: 2026-09-17 · Category: Developer