40,314
stars
+11
1,973
forks
404
watchers
512
prs
3,038
issues
30
releases
0
discussions
README
ShellCheck - A shell script static analysis tool
ShellCheck is a GPLv3 tool that gives warnings and suggestions for bash/sh shell scripts:
!Screenshot of a terminal showing problematic shell script lines highlighted
The goals of ShellCheck are
To point out and clarify typical beginner's syntax issues that cause a shell
to give cryptic error messages.
To point out and clarify typical intermediate level semantic problems that
cause a shell to behave strangely and counter-intuitively.
To point out subtle caveats, corner cases and pitfalls that may cause an
advanced user's otherwise working script to fail under future circumstances.
See the gallery of bad code for examples of what ShellCheck can help you identify!
Table of Contents
How to use
On the web
From your terminal
In your editor
In your build or test suites
Installing
Compiling from source
Installing Cabal
Compiling ShellCheck
Running tests
Gallery of bad code
Quoting
Conditionals
Frequently misused commands
Common beginner's mistakes
Style
Data and typing errors
Robustness
Portability
Miscellaneous
Testimonials
Ignoring issues
Reporting bugs
Contributing
Copyright
Other Resources
How to use
There are a number of ways to use ShellCheck!
On the web
Paste a shell script on for instant feedback.
ShellCheck.net is always synchronized to the latest git commit, and is the easiest way to give ShellCheck a go. Tell your friends!
From your terminal
Run shellcheck yourscript in your terminal for instant output, as seen above.
In your editor
You can see ShellCheck suggestions directly in a variety of editors.
Vim, through ALE, Neomake, or Syntastic:
!Screenshot of Vim showing inlined shellcheck feedback.
Emacs, through Flycheck or Flymake:
!Screenshot of emacs showing inlined shellcheck feedback.
Sublime, through SublimeLinter.
Pulsar Edit (former Atom), through linter-shellcheck-pulsar.
VSCode, through vscode-shellcheck.
Most other editors, through GCC error compatibility.
In your build or test suites
While ShellCheck is mostly intended for interactive use, it can easily be added to builds or test suites.
It makes canonical use of exit codes, so you can just add a shellcheck command as part of the process.
For example, in a Makefile:
Makefile
check-scripts:
Fail if any of these files have warnings
shellcheck myscripts/.sh
or in a Travis CI .travis.yml file:
yaml
script:
Fail if any of these files have warnings
- shellcheck myscripts/.sh
Services and platforms that have ShellCheck pre-installed and ready to use:
Travis CI
Codacy
Code Climate
Code Factor
Codety via the Codety Scanner
CircleCI via the ShellCheck Orb
Github (only Linux)
Trunk Code Quality (universal linter; allows you to explicitly version your shellcheck install) via the shellcheck plugin
CodeRabbit
Most other services, including GitLab, let you install
ShellCheck yourself, either through the system'sTop issues
#809Support zsh74 comments · 2016-12-25#380Sometimes too overzealous in regards to unquoted variables58 comments · 2015-05-20#143Check directories recursively40 comments · 2014-04-24#356Support for pre-declared "external" globals for sourced scripts to avoid SC2154 warnings.26 comments · 2015-04-23#1602Kernel requirement22 comments · 2019-06-07#2011Add exclude/include rules for files and directories (with glob patterns)20 comments · 2020-07-09#1411shellcheck doesn't warn against misspelled function names20 comments · 2018-12-11#1210Add support for #!/usr/bin/env nix-shell20 comments · 2018-05-09
Latest release
Stable version v0.11.0 v0.11.0 2025-08-04This release is dedicated to Satisfactory, even though my giant 3D ball of rat's nest conveyor belt spaghetti is anything but. CHANGELOG v0.11.0 - 2025-08-03 Added - SC2327/SC2328: Warn about capturing the output of redirected commands. - SC2329: Warn when (non-escaping) functions are never invoked. - SC2330: Warn about unsupported glob matches with [[ .. ]] in BusyBox. - SC2331: Suggest using standard -e instead of unary -a in tests. - SC2332: Warn about [ ! -o opt ] being unconditionally true in Bash. - SC3062: Warn about bashism [ -o opt ]. - Optional av