Skip to content
Latchkey

shellcheck: Exclude SC Codes and Disable

shellcheck suppresses specific checks with --exclude codes on the command line, disable= in .shellcheckrc, or a # shellcheck disable comment in the script.

When a finding is a deliberate false positive, you silence just that SC code, ideally inline with a reason, not by lowering the whole gate.

What it does

Every check has an SCxxxx code. --exclude=SC2086,SC2034 hides those globally; a disable=SC2086 line in .shellcheckrc does the same for the project; and # shellcheck disable=SC2086 above a line suppresses it there only.

Common usage

Terminal
# globally exclude two codes
shellcheck --exclude=SC2086,SC1091 script.sh
# inline, just for the next command
# shellcheck disable=SC2086
rm $files
# .shellcheckrc
# disable=SC1091

Options

MechanismWhat it does
--exclude=<codes>Comma-separated SC codes ignored for the run
# shellcheck disable=<codes>Inline suppression for the next line
# shellcheck source=<file>Tell ShellCheck where a sourced file lives
disable=<codes> (.shellcheckrc)Project-wide suppression
--include=<codes>Run only the listed codes

In CI

Prefer inline # shellcheck disable=SCxxxx with a comment explaining why, over a blanket --exclude, so suppressions stay local and reviewable. Keep .shellcheckrc in the repo root so local and CI runs exclude the same codes.

Common errors in CI

An inline directive that does not work is usually misplaced: it must sit on the line directly above the command, with no blank line between. "SC1091" persisting after a source= directive means the path is still unresolved; give an absolute or correct relative path.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →