ci / tests (macos-latest, python 3.11) (push) Canceled after 0s
ci / tests (macos-latest, python 3.13) (push) Canceled after 0s
ci / tests (macos-latest, python 3.9) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.11) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.13) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.9) (push) Canceled after 0s
Contracts with a ladder of checks, an end-of-turn gate, retrospectives and shared lessons, time-to-delivery measurement, a library of 140 verification techniques and 20 recipes, personal data kept outside the clone, and releases with rollback. Standard library only. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2.0 KiB
2.0 KiB
id, title, answers, rung, section, languages, kinds, cost, detect, ran_here, verified
| id | title | answers | rung | section | languages | kinds | cost | detect | ran_here | verified |
|---|---|---|---|---|---|---|---|---|---|---|
| shellcheck | ShellCheck for shell scripts | Do my shell scripts have quoting, word-splitting or portability bugs? | 2 | safety | any | general | low | shellcheck --version | yes | ran |
Use when
- You wrote or changed any
.shscript, CI step, git hook orjustrecipe body in bash. - A script deletes, moves or loops over files, where an unquoted variable can be destructive.
- A script must run on more than one shell (
sh,dash,bash).
Do not use when
- The script is a few lines of fixed commands with no variables. Run it instead.
- You need to know the script produces the right result; ShellCheck cannot say so. Run it on test input.
Set up
shellcheck --version # package manager: pacman -S shellcheck, apt install shellcheck
Minimal example
bad.sh:
#!/usr/bin/env bash
for f in $(ls *.txt); do rm $f; done
Run
shellcheck --severity=warning --shell=bash bad.sh
git ls-files '*.sh' | xargs -r shellcheck -x --severity=warning
Passing looks like: no output, exit 0. Failure here (run on this machine,
v0.11.0) prints SC2045 (error): Iterating over ls output is fragile. Use globs.
and exits 1. -x follows sourced files. Pick the shell with --shell or a
# shellcheck shell=bash line, or the wrong dialect is checked. Fix the cause;
only disable a code with # shellcheck disable=SC2034 plus a comment saying why.
As a contract check
{"id": "shellcheck", "claim": "All shell scripts pass ShellCheck at warning level", "kind": "general", "rung": 2, "cmd": "git ls-files '*.sh' | xargs -r shellcheck -x --severity=warning", "expect": {"exit": 0}, "tier": "deep", "timeout_s": 120}
What a pass does not prove
It checks syntax and well-known pitfalls only. set -euo pipefail mistakes,
logic errors, and wrong command arguments pass. Scripts without a .sh
extension or only a shebang (bin/tool) are skipped by the git ls-files '*.sh'
glob, so list them. A file full of disable= comments passes: grep the diff.