shellcheck
Statically check shell scripts for errors, usage of deprecated/insecure features, and bad practices.
More info →Options (6)
-s, --shellbooleanCheck a shell script interpreting it as the specified shell dialect (overrides the shebang at the top of the script)
shellcheck {{[-s|--shell]}} {{sh|bash|dash|ksh}} {{path/to/script.sh}}-e, --excludebooleanIgnore one or more error types
shellcheck {{[-e|--exclude]}} {{SC1009,SC1073,...}} {{path/to/script.sh}}-a, --check-sourcedbooleanAlso check any sourced shell scripts
shellcheck {{[-a|--check-sourced]}} {{path/to/script.sh}}-f, --formatbooleanDisplay output in the specified format (defaults to `tty`)
shellcheck {{[-f|--format]}} {{tty|checkstyle|diff|gcc|json|json1|quiet}} {{path/to/script.sh}}-o, --enablebooleanEnable one or more [o]ptional checks
shellcheck {{[-o|--enable]}} {{add-default-case,avoid-nullary-conditions,...}} {{path/to/script.sh}}-S, --severitybooleanAdjust the level of severity to consider (defaults to `style`)
shellcheck {{[-S|--severity]}} {{error|warning|info|style}} {{path/to/script.sh}}Examples (8)
Check a shell script
shellcheck path/to/script.shCheck a shell script interpreting it as the specified shell dialect (overrides the shebang at the top of the script)
shellcheck [-s|--shell] sh|bash|dash|ksh path/to/script.shIgnore one or more error types
shellcheck [-e|--exclude] SC1009,SC1073,... path/to/script.shAlso check any sourced shell scripts
shellcheck [-a|--check-sourced] path/to/script.shDisplay output in the specified format (defaults to `tty`)
shellcheck [-f|--format] tty|checkstyle|diff|gcc|json|json1|quiet path/to/script.shEnable one or more [o]ptional checks
shellcheck [-o|--enable] add-default-case,avoid-nullary-conditions,... path/to/script.shList all available optional checks that are disabled by default
shellcheck --list-optionalAdjust the level of severity to consider (defaults to `style`)
shellcheck [-S|--severity] error|warning|info|style path/to/script.sh