Bash Debugger — Find the Bug Without Running the Script
A bash debugger for when you can't (or shouldn't) execute the script. Paste it and get a static bug hunt: unset variables, exit-code assumptions, race conditions, and quoting bugs — all line-anchored.
Bug the debugger surfaces
process() {
local tmp=$(mktemp)
do_work > $tmp # debugger: race — another instance can overwrite $tmp path if hardcoded
# ...
} # debugger: local `tmp` is fine, but the redirect above should quote "$tmp"
What the debugger explains
For every finding it names the line, why the bug fires (unset expansion, silent failure, subshell state loss), and the exact conditions under which the script will misbehave. No guesswork — just static evidence.
When static beats runtime debugging
When the script is destructive (`rm`, `dd`, `mkfs`), when it requires production credentials, or when the failing environment is hard to reproduce. Static analysis needs no reproduction.
Common bugs it catches
Silent failure with `set -e` disabled, missing `pipefail`, `local var=$(cmd)` masking exit codes, unquoted expansions eating whitespace, subshell traps that never trigger, and heredoc expansion surprises.
Frequently asked questions
- Does the debugger execute my script?
- No. That's the whole point — you can debug destructive or credential-requiring scripts safely.
- Can it detect infinite loops?
- It flags common patterns (missing break, unbounded while read without EOF handling) but cannot prove halting for arbitrary loops.
- Does it work on functions inside a larger script?
- Yes — paste the whole script. Findings are grouped by function and line.