A shell script static analysis tool
open sourceGPL-3.0-or-laterself-hostablefree
ShellCheck finds bugs in sh and bash scripts and explains them: quoting mistakes, broken conditionals, misused commands, beginner syntax errors and subtle portability problems, each with a wiki page per warning code. It runs in the terminal, in editors (Vim, Emacs, Sublime and most others through GCC-style output), in CI and as a pre-commit hook, and shellcheck.net checks a pasted script in the browser. Vidar Holen wrote it in Haskell, under GPL-3.0.
Ways to install
Package managers
Problems it solves
- my bash script works on my machine and breaks on filenames with spaces
- find bugs in shell scripts before they run in production
- lint all the shell scripts in our repo on every pull request
- explain why bash gives me a cryptic syntax error
- check that a script is portable to plain sh and dash, not just bash
- see warnings about unquoted variables right in my editor
- paste a shell script into a website and get it reviewed
Features
- warnings and suggestions for sh, bash, dash and ksh scripts
- a wiki page for every warning code
- web version at shellcheck.net
- editor integration via GCC-compatible output
- pre-commit hook
- Docker image
- inline directives to ignore specific warnings
Limitations
- Doesn't check Zsh, Csh, Tcsh or PowerShell scripts: it supports only bash, ksh, dash and POSIX sh5
Capabilities
| Has a command line tool | plan not known |
|---|
Alternatives
The same job
These do what ShellCheck does.
- actionlint Static checker for GitHub Actions workflow files
- ansible-lint Checks playbooks for practices and behavior that could potentially be improved
- TFLint A Pluggable Terraform Linter
- Hadolint Dockerfile linter that checks best practices and the shell in RUN lines
