Reformated.

Matthew O. Persico
2018-03-30 23:16:28 -04:00
parent b41e9e89d8
commit 5666490a0b

@@ -1,26 +1,31 @@
Shellcheck directives allows you to selectively [[ignore]] warnings, and takes the form of comments in files: Shellcheck directives allow you to control how `shellcheck` works, and take the form of comments in files:
hexToAscii() { hexToAscii() {
# shellcheck disable=SC2059 # shellcheck disable=SC2059
printf "\x$1" printf "\x$1"
} }
Supported directives are `disable` to disable warnings: Supported directives are
### disable
Prevent shellcheck from processing one or more warnings:
# shellcheck disable=code[,code...] # shellcheck disable=code[,code...]
statement_where_warning_should_be_disabled statement_where_warning_should_be_disabled
`source` to tell ShellCheck where to find a sourced file (since 0.4.0): ### source
Tell ShellCheck where to find a sourced file (since 0.4.0):
# shellcheck source=src/examples/config.sh # shellcheck source=src/examples/config.sh
. "$(locate_config)" . "$(locate_config)"
`shell`, as a top level directive, to specify the shell for a script (similar to the shebang, if you for any reason don't want to add one) (since [0.4.5](https://github.com/koalaman/shellcheck/issues/581#issuecomment-249437837)): ### shell
Specify the shell for a script (similar to the shebang, if you for any reason don't want to add one) (since [0.4.5](https://github.com/koalaman/shellcheck/issues/581#issuecomment-249437837)):
# shellcheck shell=sh # shellcheck shell=sh
echo foo &> bar echo foo &> bar
Directives instead of or immediately after the shebang apply to the entire script. Otherwise, they are scoped to the structure that follows it (such as all branches of a `case` statement, or an entire function). Directives that replace or are immediately after the shebang apply to the entire script. Otherwise, they are scoped to the structure that follows it (such as all branches of a `case` statement, or an entire function).
*Note: There is a [known bug](../issues/1036) in the current version when directives appear within `then` clauses of `if` blocks that causes Shellcheck to report SC1072 on otherwise valid code. Avoid using directives within `then` clauses - instead place them at the top of the `if` block or another enclosing block. This is fixed on the [online version](https://www.shellcheck.net/) and the next release.* *Note: There is a [known bug](../issues/1036) in the current version when directives appear within `then` clauses of `if` blocks that causes Shellcheck to report SC1072 on otherwise valid code. Avoid using directives within `then` clauses - instead place them at the top of the `if` block or another enclosing block. This is fixed on the [online version](https://www.shellcheck.net/) and the next release.*
@@ -29,10 +34,11 @@ There is no support for scoping a directive to the first structure of the script
# This directive applies to the entire script # This directive applies to the entire script
# shellcheck disable=2086 # shellcheck disable=2086
true true
# This directive only applies to this function # This directive only applies to this function
# shellcheck disable=2043 # shellcheck disable=2043
f() { f() {
... ...
} }
Silencing parser errors is purely cosmetic, and will not make ShellCheck continue. Silencing parser errors is purely cosmetic; any parser error found will still stop ShellCheck at the point of the error.