ShellCheck is a shell script static analysis tool written in Haskell. It gives various warnings about shell scripts — mainly syntax and semantic problems related to the typical beginner issues, counter-intuitive behavior, or various corner cases.
USE flags for dev-util/shellcheck Shell script analysis tool
||Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally|
||Include coloured haskell sources to generated documentation (dev-haskell/hscolour)|
||Add support for software performance analysis (will likely vary from ebuild to ebuild)|
||Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)|
The binary version is intended for systems with no Haskell toolchain present.
Binary package (shellcheck-bin)
emerge --ask dev-util/shellcheck-bin
emerge --ask dev-util/shellcheck
ShellCheck's behavior can be modified using directives (like disable or enable) directly in the validated script or using configuration files:
- ~/.shellcheckrc - Local (per user) configuration file.
- /home/larry/project/.shellcheckrc - Per project configuration file.
Script validation with an example error output:
In validated-script.sh line 5: echo $DATE ^---^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: echo "$DATE" For more information: https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...
- Shell — command-line interpreter that offers a text-based interface to users.
- ShellCheck: SC1008, GitHub. Retrieved on January 30, 2023