ShellCheck – display warnings and suggestions for shell scripts.
ShellCheck is a static analysis tool that displays warnings and recommendations about poor code in bash/sh shell scripts. It may be accessed over the web by putting your shell script into an online editor
You may also install it on your computer and run it from the terminal, as well as integrate it with your text editor and build or test suites.
ShellCheck mainly performs three functions:
- It identifies and discusses common beginner syntax errors that cause a shell to return confusing error messages.
- It identifies and discusses common intermediate-level semantic issues that lead a shell to act oddly and counter-intuitively.
- It also highlights minor limitations, corner instances, and dangers that may cause an otherwise functioning script by an expert user to fail in the future. In this post, we’ll teach you how to install and utilize ShellCheck in a variety of ways to detect flaws or poor code in your Linux shell scripts.
Installing and Using ShellCheck in Linux
ShellCheck is simple to install locally using your package manager, as demonstrated.
Debian/Ubuntu:
shellcheck apt-get install
Install ShellCheck on macOS and Unix.
$ brew install
Using ShellCheck from the Command Line
After ShellCheck is installed you can run it from the command line
$ shellcheck my-script.sh