Directive – ShellCheck Wiki

See this page on GitHub

Sitemap


shellcheck directives

Shellcheck directives allow you to control how shellcheck works, and can be added:

  1. As entries in a .shellcheckrc file in the project's root-, or user's home-, directory:

    # Don't suggest [ -n "$VAR" ] over [ ! -z "$VAR" ]
    disable=SC2236
    
    # Suggest ${VAR} in place of $VAR
    enable=require-variable-braces
  2. and/Or as comments inside individual script files:

    hexToAscii() {
        # shellcheck disable=SC2059
        printf "\x$1"
    }

Directives that replace or are immediately after the shebang apply to the entire script. Otherwise, they are scoped to the command that follows it. (including compound commands like function definitions, loops and case statements)

Documenting directive use

It is recommended to add a comment to document why a specific directive was used.

.shellcheckrc file

Unless the --norc option is used;

Supported directives

disable

enable

external-sources

source

source-path

shell

Supported options

--rcfile

others


ShellCheck is a static analysis tool for shell scripts. This page is part of its documentation.