What is ShellCheck?
ShellCheck is a free and open source static analysis tool for shell scripts crafted and maintained by Vidar Holen and 142+ Contributors.
- 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.
How to use ShellCheck:
- On the web: Paste a shell script on shellcheck.net for instant feedback.
- 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 such as Vim, Emacs, Sublime, Atom and VSCode.
- 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 Services and platforms that have ShellCheck pre-installed, It's a good idea to manually install a specific ShellCheck version regardless. This avoids any surprise build breaks when a new version with new warnings is published.
For customized filtering or reporting, ShellCheck can output simple JSON, CheckStyle compatible XML, GCC compatible warnings as well as human readable text (with or without ANSI colors).