About this project
ShellCheck is a static analysis tool for bash/sh shell scripts, released under the GNU GPLv3. It scans scripts and reports warnings and suggestions rather than executing them.
Stated goals include clarifying beginner syntax issues that produce cryptic shell errors, intermediate-level semantic problems that make shells behave counter-intuitively, and subtle caveats or corner cases that can break otherwise working scripts later.
The README documents a broad gallery of detected issue categories: quoting problems (unquoted variables, quoted tilde expansion, literal quotes in variables, prematurely expanded traps), conditional mistakes (constant test expressions, missing spaces, quoted regex in =~, unsupported [ ] operators), frequently misused commands (globs in regex contexts, redirecting sudo, misused exec, implicit find precedence), beginner syntax errors (spaces around = in assignments, comma-separated arrays, else if), style suggestions (useless cat, backticks vs $(), redirection blocks), data and typing errors (arrays assigned to strings, printf argument count mismatches, assignments in subshells), robustness concerns (catastrophic rm, globs that could become options, find -exec shell injection), and portability warnings tied to the shebang, similar to checkbashisms.
Usage options described: pasting scripts on shellcheck.net, running `shellcheck yourscript` in a terminal, editor integrations (Vim via ALE/Neomake/Syntastic, Emacs via Flycheck/Flymake, Sublime via SublimeLinter, Pulsar, VSCode, and GCC error compatibility for other editors), and inclusion in build or test suites using exit codes, with examples for Makefiles and Travis CI. The README notes pre-installed availability on services such as Travis CI, Codacy, Code Climate, Code Factor, CircleCI, GitHub Actions (Linux only), Trunk Code Quality, and CodeRabbit, and recommends pinning a specific version to avoid surprise build breaks.
Output formats include human-readable text with or without ANSI colors, JSON, CheckStyle-compatible XML, and GCC-compatible warnings, with integration documentation on the project wiki.
Installation is covered through many package managers (Cabal, Stack, apt, pacman, emerge, yum, dnf, pkg, Homebrew, MacPorts, zypper, eopkg, Chocolatey, winget, scoop, conda-forge, Snap, Nix, Flox), Docker images (koalaman/shellcheck and shellcheck-alpine), pre-compiled binaries for Linux x86_64/armv6hf/aarch64, macOS aarch64/x86_64, and Windows x86, plus a pre-commit hook configuration. Building from source requires Haskell and Cabal, with roughly 2GB of RAM noted for compilation, and tests run via `cabal test`.
Issues can be ignored via environment variable, command line, individually, or globally within a file. Contributions are accepted as GitHub pull requests under GPLv3, and the README points to the wiki for long-form descriptions of each warning code and to shfmt for formatting, which ShellCheck deliberately does not enforce.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.