# bash

> Shell scripts, hooks, and task files: lint, formatting, syntax, and the structure rules for shell.

Shell scripts, hooks, and task files: lint, formatting, syntax, and the structure rules for shell.

## Checks

| Check                                                               | Stage    | Level         | What it does                                                                                                                                           |
| ------------------------------------------------------------------- | -------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [`bash/zsh-syntax`](/reference/checks/bash/zsh-syntax/)             | `commit` | `recommended` | Checks the syntax of Zsh scripts with `zsh -n`.                                                                                                        |
| [`bash/shellcheck`](/reference/checks/bash/shellcheck/)             | `commit` | `recommended` | Runs ShellCheck over shell scripts and sourced files, with its stable optional rules at level all.                                                     |
| [`bash/shfmt`](/reference/checks/bash/shfmt/)                       | `commit` | `recommended` | Checks that every shell script matches the shfmt output.                                                                                               |
| [`bash/script-layout`](/reference/checks/bash/script-layout/)       | `commit` | `all`         | Checks each Bash script for a shebang, strict mode, a final `main` call when it defines functions, declarative libraries, and removed temporary files. |
| [`bash/doc-comments`](/reference/checks/bash/doc-comments/)         | `commit` | `all`         | Checks that each shell function has a comment above it that says more than its name.                                                                   |
| [`bash/unused-functions`](/reference/checks/bash/unused-functions/) | `commit` | `recommended` | Finds shell functions no script in the scope calls.                                                                                                    |
| [`bash/unread-arguments`](/reference/checks/bash/unread-arguments/) | `commit` | `recommended` | Finds shell functions called with arguments they never read.                                                                                           |
| [`bash/function-size`](/reference/checks/bash/function-size/)       | `commit` | `all`         | Checks every shell function against the size ceilings: code lines, branches, nesting, and assignments.                                                 |
| [`bash/inline-scripts`](/reference/checks/bash/inline-scripts/)     | `commit` | `all`         | Finds inline Python and Node code, and heredocs piped into an interpreter, in shell scripts.                                                           |
| [`bash/safety`](/reference/checks/bash/safety/)                     | `commit` | `recommended` | Finds broad process kills and recursive deletes, except traps that remove mktemp paths. At level all, also reports discarded failures.                 |

## Selected when

gspot selects it in a scope with file extensions `.sh`, `.bash`, `.zsh`, `.bats`, or script interpreters `shell`.

## Rules for coding agents

| Rule file                                                 | Installed when |
| --------------------------------------------------------- | -------------- |
| `.gspot/configurations/language/bash/rules/BASH.md`       | Always         |
| `.gspot/configurations/language/bash/rules/LANGUAGE.md`   | Always         |
| `.gspot/configurations/language/bash/rules/OPERATIONS.md` | Always         |
| `.gspot/configurations/language/bash/rules/SAFETY.md`     | Always         |

## Tools and versions

| Tool       | Version                  |
| ---------- | ------------------------ |
| shellcheck | `0.11.0`                 |
| shfmt      | `3.12.0`                 |
| zsh        | Any, install it yourself |

## Files gspot writes

gspot writes `.gspot/configurations/language/bash/shellcheckrc` and `.gspot/configurations/language/bash/semgrep.yml` (with the [`security`](/reference/configurations/security/) configuration).
