]> git.proxmox.com Git - mirror_zfs.git/blame - config/Shellcheck.am
etc/init.d: decide which variant to use at build time.
[mirror_zfs.git] / config / Shellcheck.am
CommitLineData
5cdca5b1 1# Global ShellCheck exclusions:
8df0bde3
DS
2#
3# ShellCheck can't follow non-constant source. Use a directive to specify location. [SC1090]
4# Not following: a was not specified as input (see shellcheck -x). [SC1091]
5# Prefer putting braces around variable references even when not strictly required. [SC2250]
a5087965 6# Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore). [SC2312]
13ec73a0 7# Command appears to be unreachable. Check usage (or ignore if invoked indirectly). [SC2317]
8df0bde3
DS
8# In POSIX sh, 'local' is undefined. [SC2039] # older ShellCheck versions
9# In POSIX sh, 'local' is undefined. [SC3043] # newer ShellCheck versions
5cdca5b1
AZ
10
11SHELLCHECKSCRIPTS =
12
13JUST_SHELLCHECK_OPTS = $(addprefix shellcheck-here-,$(subst /,^,$(1)))
14JUST_CHECKBASHISMS_OPTS = $(addprefix checkbashisms-here-,$(subst /,^,$(1)))
15SHELLCHECK_OPTS = $(call JUST_SHELLCHECK_OPTS,$(1)) $(call JUST_CHECKBASHISMS_OPTS,$(1))
16
0425d588 17PHONY += shellcheck
5cdca5b1
AZ
18
19_STGT = $(subst ^,/,$(subst shellcheck-here-,,$@))
20shellcheck-here-%:
c3ef9f75 21if HAVE_SHELLCHECK
13ec73a0 22 shellcheck --format=gcc --enable=all --exclude=SC1090,SC1091,SC2039,SC2250,SC2312,SC2317,SC3043 $$([ -n "$(SHELLCHECK_SHELL)" ] && echo "--shell=$(SHELLCHECK_SHELL)") "$$([ -e "$(_STGT)" ] || echo "$(srcdir)/")$(_STGT)"
c3ef9f75 23else
5cdca5b1 24 @echo "skipping shellcheck of" $(_STGT) "because shellcheck is not installed"
c3ef9f75 25endif
5cdca5b1 26
0425d588 27shellcheck: $(SHELLCHECKSCRIPTS) $(call JUST_SHELLCHECK_OPTS,$(SHELLCHECKSCRIPTS))
f7d7ee05 28
5cdca5b1 29
0425d588 30PHONY += checkbashisms
5cdca5b1 31
f7d7ee05 32# command -v *is* specified by POSIX and every shell in existence supports it
5cdca5b1
AZ
33_BTGT = $(subst ^,/,$(subst checkbashisms-here-,,$@))
34checkbashisms-here-%:
f7d7ee05 35if HAVE_CHECKBASHISMS
5cdca5b1
AZ
36 ! { [ -n "$(SHELLCHECK_SHELL)" ] && echo '#!/bin/$(SHELLCHECK_SHELL)'; cat "$$([ -e "$(_BTGT)" ] || echo "$(srcdir)/")$(_BTGT)"; } | \
37 checkbashisms -npx 2>&1 | grep -vFe "'command' with option other than -p" -e 'command -v' -e 'any possible bashisms' $(CHECKBASHISMS_IGNORE) >&2
f7d7ee05 38else
5cdca5b1 39 @echo "skipping checkbashisms of" $(_BTGT) "because checkbashisms is not installed"
f7d7ee05 40endif
5cdca5b1 41
0425d588 42checkbashisms: $(SHELLCHECKSCRIPTS) $(call JUST_CHECKBASHISMS_OPTS,$(SHELLCHECKSCRIPTS))