Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

shellcheck

Stow package for ~/.shellcheckrc. shellcheck is the de-facto shell script linter. Used by lefthook on pre-commit, ALE in vim, and by hand.

Table of contents

Layout

FileStows to
shellcheck/.shellcheckrc~/.shellcheckrc

What’s enabled / disabled

enable=all
shell=bash
external-sources=true

disable=SC2034   # variable appears unused (false positive in sourced libs)
disable=SC1090   # can't follow non-constant source
disable=SC1091   # can't find source file

The enable=all turns on shellcheck’s optional checks (literal numeric comparison, etc.) — more signal at the cost of slightly more verbose output. The three disabled codes are the ones that fire most often on legitimate code (utility scripts that source siblings, library files that define helpers their callers use, etc.).

Per-project overrides

Each rule can be re-enabled in a single file via a comment:

#!/usr/bin/env bash
# shellcheck enable=SC2034

Or per-line:

foo=bar  # shellcheck disable=SC2034

A repo can also drop its own .shellcheckrc at the root; it wins.

Fresh-machine setup

brew install shellcheck    # in the Brewfile
stow shellcheck