Shell script docs drift
Rimfe parses changed .sh, .bash and .zsh files without running them. It records functions, upper-case variables, flags handled in a case "$1" block or by getopts, and environment variables the script reads with a fallback default. A docs page or snippet that still uses a renamed flag, variable or default gets a finding.
What Rimfe reads
Install scripts, release scripts and developer tooling are often the first thing a README tells people to run. Rimfe reads them like any other code and compares each pull request between its base and head.
| Surface | What is read |
|---|---|
| Functions | Every function. A name that starts with _ is internal. The doc comment after the shebang describes the script. |
| Variables | Top-level UPPER_CASE assignments. export marks them exported. |
| Flags | Branches of a case "$1" in block such as -e|--env), named by the long form. A branch that reads "$2" or runs shift 2 takes a value. getopts "o:v" letters, where : means a value. |
| Env vars | ${NAME:-default}, ${NAME:=default} and ${NAME:?message} for names the script never assigns, with the default read. |
Example: a flag is renamed
The README tells readers to run ./scripts/deploy.sh --env staging. Flags match snippets in any language, so that shell block is reported as an Outdated code sample naming the README line.
case "$1" in- -e|--env) TARGET="$2"; shift 2 ;;+ -t|--target) TARGET="$2"; shift 2 ;;Example: a default port changes
docs/running.md says the server listens on 8080 unless PORT is set. Rimfe reads the new default and posts a Docs conflict on that line, with an edit to 3000.
- exec ./bin/server --port "${PORT:-8080}"+ exec ./bin/server --port "${PORT:-3000}"Where shell scripts are documented
Most scripts are documented in a README, a CONTRIBUTING.md or a development page in docs/. Rimfe treats CONTRIBUTING.md and docs/contributing/** as internal docs by default, and you can set the audience of any glob with audiences.
Set up a repository with scripts
Map scripts to the pages that tell people to run them. surface adds the flags and variables that matter to docs coverage. The file applies when Documentation scope is set to .rimfe.json at the PR base.
{ "$schema": "https://rimfe.com/schema/rimfe.json", "docsGlobs": ["README.md", "CONTRIBUTING.md", "docs/**/*.md"], "codeMappings": [ { "source": "install.sh", "target": "README.md" }, { "source": "scripts/**", "target": "docs/development.md" } ], "surface": ["ACME_HOME", "--target"]}Limits
- Flags come from
case "$1"branches andgetoptsonly. A flag parsed another way, such asif [ "$1" = --force ], is not read. - A script is parsed as shell by its extension. An executable without
.sh,.bashor.zsh, such asbin/acme, is not parsed as shell. - A name the script assigns anywhere, as in
PORT="${PORT:-8080}", is not read as an env var, so its default is not compared as one. Read it inline, as in the example above. - Fish and PowerShell scripts are not parsed.
Try it on your next pull request.
Free for public repositories, with unlimited members.
Start free with GitHub