1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-29 23:24:55 +02:00
tldr/pages/common/shellcheck.md

37 lines
1.2 KiB
Markdown
Raw Normal View History

2018-06-20 07:12:26 -04:00
# shellcheck
> Statically check shell scripts for errors, usage of deprecated/insecure features, and bad practices.
> More information: <https://github.com/koalaman/shellcheck/wiki>.
2018-06-20 07:12:26 -04:00
- Check a shell script:
2021-04-16 09:15:12 -04:00
`shellcheck {{path/to/script.sh}}`
2018-06-20 07:12:26 -04:00
- Check a shell script interpreting it as the specified shell dialect (overrides the shebang at the top of the script):
2018-06-20 07:12:26 -04:00
`shellcheck {{[-s|--shell]}} {{sh|bash|dash|ksh}} {{path/to/script.sh}}`
2018-06-20 07:12:26 -04:00
- Ignore one or more error types:
2018-06-20 07:12:26 -04:00
`shellcheck {{[-e|--exclude]}} {{SC1009,SC1073,...}} {{path/to/script.sh}}`
2018-06-20 07:12:26 -04:00
2021-04-16 09:15:12 -04:00
- Also check any sourced shell scripts:
2018-06-20 07:12:26 -04:00
`shellcheck {{[-a|--check-sourced]}} {{path/to/script.sh}}`
2021-04-16 09:15:12 -04:00
- Display output in the specified format (defaults to `tty`):
2021-04-16 09:15:12 -04:00
`shellcheck {{[-f|--format]}} {{tty|checkstyle|diff|gcc|json|json1|quiet}} {{path/to/script.sh}}`
2021-04-16 09:15:12 -04:00
- Enable one or more [o]ptional checks:
2021-04-16 09:15:12 -04:00
`shellcheck {{[-o|--enable]}} {{add-default-case,avoid-nullary-conditions,...}} {{path/to/script.sh}}`
2021-04-16 09:15:12 -04:00
- List all available optional checks that are disabled by default:
`shellcheck --list-optional`
- Adjust the level of severity to consider (defaults to `style`):
`shellcheck {{[-S|--severity]}} {{error|warning|info|style}} {{path/to/script.sh}}`