Updated Directive (markdown)

Vidar Holen
2021-07-27 19:35:18 -07:00
parent 80e8e1d8d7
commit c7be0d3e5e

@@ -1,3 +1,5 @@
# ShellCheck Directives
Shellcheck directives allow you to control how `shellcheck` works, and take the form of comments in files: Shellcheck directives allow you to control how `shellcheck` works, and take the form of comments in files:
```sh ```sh
@@ -7,6 +9,18 @@ hexToAscii() {
} }
``` ```
or entries in a `.shellcheckrc` in the project root or user's home directory:
```none
$ cat ~/.shellcheckrc
# Don't suggest [ -n "$VAR" ] over [ ! -z "$VAR" ]
disable=SC2236
# Suggest ${VAR} in place of $VAR
enable=require-variable-braces
```
## Supported directives ## Supported directives
### disable ### disable
@@ -23,6 +37,18 @@ A range of errors can also be specified, handy when disbaling things for the ent
# shellcheck disable=SC1000-SC9999 # shellcheck disable=SC1000-SC9999
``` ```
### enable
Enables an [[optional]] check (since 0.7.0).
```sh
#!/bin/bash
# shellcheck enable=require-variable-braces
echo "Hello $USER" # Will suggest ${USER}
```
To see a list of optional checks with examples, run `shellcheck --list-optional`. See [[here|optional]] for more information.
### source ### source
Tell ShellCheck where to find a sourced file (since 0.4.0): Tell ShellCheck where to find a sourced file (since 0.4.0):