From c7be0d3e5efb7c7ae1b059b2887bfd927f078778 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Tue, 27 Jul 2021 19:35:18 -0700 Subject: [PATCH] Updated Directive (markdown) --- Directive.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Directive.md b/Directive.md index 39c8bd7..7f2150c 100644 --- a/Directive.md +++ b/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: ```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 ### disable @@ -23,6 +37,18 @@ A range of errors can also be specified, handy when disbaling things for the ent # 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 Tell ShellCheck where to find a sourced file (since 0.4.0):