From ce46a2e8dd84a0092196573bedfba16bba2b66d1 Mon Sep 17 00:00:00 2001 From: koalaman Date: Tue, 8 Mar 2016 20:04:19 -0800 Subject: [PATCH] Updated Directive (markdown) --- Directive.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Directive.md b/Directive.md index 4fc6cca..ec45d67 100644 --- a/Directive.md +++ b/Directive.md @@ -10,11 +10,27 @@ Supported directives are `disable` to disable warnings: # shellcheck disable=code[,code...] statement_where_warning_should_be_disabled -and `source` to tell ShellCheck where to find a sourced file: +`source` to tell ShellCheck where to find a sourced file: # shellcheck source=src/examples/config.sh . "$(locate_config)" -Directives are scoped to the structure that follows it. For example, before a function it silences all warnings (or overrides all `source` statements) in the function Before a case statement, it silences all warnings in all branches of the case statement. +`shell`, as a top level directive, to specify the shell for a script (like the shebang, if you for any reason don't want to add one): + + # shellcheck shell=sh + 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). + +There is no support for scoping a directive to the first structure of the script. In these cases, use a dummy command `true` or `:` and then add directives, such as + + # This directive applies to the entire script + # shellcheck disable=2086 + true + # This directive only applies to this function + # shellcheck disable=2043 + f() { + ... + } Silencing parser errors is purely cosmetic, and will not make ShellCheck continue. \ No newline at end of file