From 250c33590eb77aa3ae88b8321dc2cae3f0d27963 Mon Sep 17 00:00:00 2001 From: bl-ue <54780737+bl-ue@users.noreply.github.com> Date: Fri, 16 Apr 2021 09:15:12 -0400 Subject: [PATCH] shellcheck: refresh (#5746) --- pages/common/shellcheck.md | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/pages/common/shellcheck.md b/pages/common/shellcheck.md index 88704e9a1..79b021d9e 100644 --- a/pages/common/shellcheck.md +++ b/pages/common/shellcheck.md @@ -1,20 +1,33 @@ # shellcheck > Shell script static analysis tool. -> More information: . +> Check shell scripts for errors, usage of deprecated/insecure features, and bad practices. +> More information: . - Check a shell script: -`shellcheck {{file.sh}}` +`shellcheck {{path/to/script.sh}}` -- Override script's shebang: +- Check a shell script interpreting it as the specified shell dialect (overrides the shebang at the top of the script): -`shellcheck --shell {{sh|bash|ksh}} {{file.sh}}` +`shellcheck --shell {{sh|bash|dash|ksh}} {{path/to/script.sh}}` -- Ignore certain errors: +- Ignore one or more error types: -`shellcheck --exclude {{SC1009}} {{file.sh}}` +`shellcheck --exclude {{SC1009,SC1073}} {{path/to/script.sh}}` -- Ignore multiple errors: +- Also check any sourced shell scripts: -`shellcheck --exclude {{SC1009,SC1073}} {{file.sh}}` +`shellcheck --checked-sourced {{path/to/script.sh}}` + +- Display output in the specified format (defaults to `tty`): + +`shellcheck --format {{tty|checkstyle|diff|gcc|json|json1|quiet}} {{path/to/script.sh}}` + +- Enable one or more optional checks: + +`shellcheck --enable={{add-default-case|avoid-nullary-conditions}}` + +- List all available optional checks that are disabled by default: + +`shellcheck --list-optional`