mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated Directive (markdown)
26
Directive.md
26
Directive.md
@@ -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):
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user