shellcheck

From RaySoft

ShellCheck is a static analysis and linting tool for sh/bash scripts. It's mainly focused on handling typical beginner and intermediate level syntax errors and pitfalls where the shell just gives a cryptic error message or strange behavior, but it also reports on a few more advanced issues where corner cases can cause delayed failures.[1]

Documentation

Syntax

shellcheck [PARAMETER ...] FILE ...

Parameters

-a, --check-sourced
Emit warnings in sourced files. Normally, shellcheck will only warn about issues in the specified files. With this option, any issues in sourced files files will also be reported.
-e CODE[,CODE,...], --exclude=CODE[,CODE,...]
Explicitly exclude the specified codes from the report. Subsequent -e options are cumulative, but all the codes can be specified at once, comma-separated as a single argument.
-s SHELL[,SHELL,...], --shell=SHELL[,SHELL,...]
Specify Bourne shell dialect. Valid values are sh, bash, dash and ksh. The default is to use the file's shebang, or bash if the target shell can't be determined.
-x, --external-sources
Follow source statements even when the file is not specified as input. By default, shellcheck will only follow files specified on the command line (plus /dev/null). This option allows following any file the script may source.

References

  1. man 1 'shellcheck'