From f28b403c07050ab1b9caa3169028514292ff3a83 Mon Sep 17 00:00:00 2001 From: John Gardner Date: Wed, 22 Dec 2021 15:55:30 +1100 Subject: [PATCH] Fix caps and add highlighting for embedded code-blocks --- Ignore.md | 59 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/Ignore.md b/Ignore.md index 19f8d6a..f90d805 100644 --- a/Ignore.md +++ b/Ignore.md @@ -1,56 +1,75 @@ ## Ignoring errors -To ignore a shellcheck error, you can do one of three things: +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" - } +```sh +hexToAscii() { + # shellcheck disable=SC2059 + printf "\x$1" +} +``` You can pass multiple errors to [[directive]]: - # shellcheck disable=SC2116,SC2086 - hash=$(echo ${hash}) # trim spaces +```sh +# shellcheck disable=SC2116,SC2086 +hash=$(echo ${hash}) # trim spaces +``` ### Ignoring errors in one specific run -Use a `-e` flag to disable a specific error when running shellcheck: +Use a `-e` flag to disable a specific error when running `shellcheck`: - $ shellcheck -e SC2059 myscript +```console +$ shellcheck -e SC2059 myscript +``` -### Ignoring one or more type of error forever +### Ignoring one or more types of errors forever As of v0.7.0 you can create a file `.shellcheckrc` in your home directory (or your project's base directory), and add `disable` directives to it: - $ cat ~/.shellcheckrc - disable=SC2059 +```shellcheckrc +# ~/.shellcheckrc +disable=SC2059,SC2034 # Disable individual error codes +disable=SC1090-SC1100 # Disable a range of error codes +``` In earlier versions, you can set the environment variable `SHELLCHECK_OPTS` in your `.bashrc`, `/etc/profile` or equivalent: - export SHELLCHECK_OPTS="-e SC2059 -e SC2034 -e SC1090" +```sh +export SHELLCHECK_OPTS="-e SC2059 -e SC2034 -e SC1090" +``` -### Ignoring one or more type of error with shellcheck in Docker +### Ignoring one or more types 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 +```sh +docker run -e SHELLCHECK_OPTS="-e SC2059 -e SC2034 -e SC1090" -v "$PWD:/mnt" koalaman/shellcheck myscript +``` Optionally you can set the `SHELLCHECK_OPTS` variable in shell: - export SHELLCHECK_OPTS="-e SC2059 -e SC2034 -e SC1090" +```sh +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 +```sh +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 +```sh +#!/bin/sh +# shellcheck disable=SC2059 +``` -Note that the [[directive]] must be on the first line after the shebang with versions before 0.4.6. As of 0.4.6 comments and whitespace are allowed before filewide directives. \ No newline at end of file +Note that the [[directive]] must be on the first line after the shebang with versions before 0.4.6. As of 0.4.6 comments and whitespace are allowed before file-wide directives.