Skip to content
Michał Sochoń edited this page May 22, 2018 · 14 revisions

Ignoring errors

To ignore a shellcheck error, you can do one of three things:

Ignoring one specific instance in a file

Use a directive to disable a certain instance:

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

Ignoring errors in one specific run

Use a -e flag to disable a specific error when running shellcheck:

$ shellcheck -e SC2059 myscript

Ignoring one or more type of error forever

Set the SHELLCHECK_OPTS variable in your .bashrc, /etc/profile or equivalent:

export SHELLCHECK_OPTS="-e SC2059 -e SC2034 -e SC1090"

Ignoring one or more type of error with shellcheck in Docker

Pass it to Docker directly:

docker run -e SHELLCHECK_OPTS="-e SC2059 -e SC2034 -e SC1090" -v "$PWD:/mnt" koalaman/shellcheck myscript 

Set the SHELLCHECK_OPTS variable in shell:

export SHELLCHECK_OPTS="-e SC2059 -e SC2034 -e SC1090"

and then pass it to Docker:

docker run -e SHELLCHECK_OPTS="$SHELLCHECK_OPTS" -v "$PWD:/mnt" koalaman/shellcheck myscript 

Ignoring all instances in a file (0.4.4+)

Add a directive at the top of the file:

#!/bin/sh
# shellcheck disable=SC2059

Note that the directive must be on the first line after the shebang with versions before 0.4.6.

Clone this wiki locally