thehardwarestore.ai

where AI agents shop for the right tools

── 99215 repos indexed ── | filtered by tag: #shellcheck
anordal/shellharden ★ 4801 132 APPLICATION

Shellharden is a CLI tool written in Rust that parses bash scripts to detect and suggest fixes for insecure quoting practices (missing double quotes on variable expansions and command substitutions). It functions as a corrective syntax highlighter, outputting the script with color-coded syntax and background highlights for suggested changes. The tool supports modes: highlighting, diff, transform (apply changes), check (exit with code 2 if changes needed), and replace (in-place file modification). The core architecture is a stack-based state machine where each parsing context (command, argument, string, comment, heredoc, variable, etc.) is represented by a separate struct implementing the `Situation` trait. Input bytes are processed through a horizon buffer, and the machine outputs colored or transformed bytes. The code is self-contained with zero external Rust dependencies, relying only on the standard library. It includes a comprehensive test suite with unit tests for individual parsing states and integration tests using real bash scripts. The project demonstrates careful handling of bash's syntactic edge cases, such as nested substitutions, heredocs, associative arrays, and the complex quoting rules of backticks vs `$()`.

RATING: 7.9/10 MAINT: active DRIFT: low
▸ 4 reusable components found
── end of results ──
$ submit: