lint/shell
Shell scripts are linted
| Severity | info |
| Tiers | all |
| Stacks | any |
| Scope | root |
| Kind | expr |
| Source | library v0.2.0 |
| Selected by | fleetlint-recommended@v0.2.0 |
Requirement
When the repository contains shell scripts, shellcheck runs as a hook (pre-commit or lefthook), in the task runner or in CI (GitHub, Gitea, Forgejo or GitLab).
Why
Unquoted variables and unchecked exit codes are the bugs shell scripts ship with, and shellcheck finds them without running anything.
Applies when
tracked().exists(p, p.endsWith(".sh"))Check
[".pre-commit-config.yaml", "lefthook.yml", "lefthook.yaml", ".lefthook.yml"].exists(f, file(f) && text(f).contains("shellcheck")) || (taskrunner.file != "" && text(taskrunner.file).contains("shellcheck")) || workflows().exists(w, text(w).contains("shellcheck"))Fix
Add the shellcheck hook to .pre-commit-config.yaml (or lefthook.yml).
Agent instruction: Add the shellcheck hook (and shfmt) to .pre-commit-config.yaml and fix what it reports in the tracked scripts.
See: https://fleetlint.org/baseline/#static-analysis
Generated by fleetlint docs from catalog v0.2.0.