]> git.proxmox.com Git - mirror_zfs.git/blob - config/Shellcheck.am
autoconf: use include directives instead of recursing down etc
[mirror_zfs.git] / config / Shellcheck.am
1 # Global ShellCheck exclusions:
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]
6 # In POSIX sh, 'local' is undefined. [SC2039] # older ShellCheck versions
7 # In POSIX sh, 'local' is undefined. [SC3043] # newer ShellCheck versions
8
9 SHELLCHECKSCRIPTS =
10
11 JUST_SHELLCHECK_OPTS = $(addprefix shellcheck-here-,$(subst /,^,$(1)))
12 JUST_CHECKBASHISMS_OPTS = $(addprefix checkbashisms-here-,$(subst /,^,$(1)))
13 SHELLCHECK_OPTS = $(call JUST_SHELLCHECK_OPTS,$(1)) $(call JUST_CHECKBASHISMS_OPTS,$(1))
14
15 PHONY += shellcheck shellcheck-recursive
16
17 shellcheck-recursive:
18 @set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir shellcheck; done
19
20 _STGT = $(subst ^,/,$(subst shellcheck-here-,,$@))
21 shellcheck-here-%:
22 if HAVE_SHELLCHECK
23 shellcheck --format=gcc --enable=all --exclude=SC1090,SC1091,SC2039,SC2250,SC3043 $$([ -n "$(SHELLCHECK_SHELL)" ] && echo "--shell=$(SHELLCHECK_SHELL)") "$$([ -e "$(_STGT)" ] || echo "$(srcdir)/")$(_STGT)"
24 else
25 @echo "skipping shellcheck of" $(_STGT) "because shellcheck is not installed"
26 endif
27
28 shellcheck: $(SHELLCHECKSCRIPTS) $(call JUST_SHELLCHECK_OPTS,$(SHELLCHECKSCRIPTS)) shellcheck-recursive
29
30
31 PHONY += checkbashisms checkbashisms-recursive
32
33 checkbashisms-recursive:
34 @set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir checkbashisms; done
35
36 # command -v *is* specified by POSIX and every shell in existence supports it
37 _BTGT = $(subst ^,/,$(subst checkbashisms-here-,,$@))
38 checkbashisms-here-%:
39 if HAVE_CHECKBASHISMS
40 ! { [ -n "$(SHELLCHECK_SHELL)" ] && echo '#!/bin/$(SHELLCHECK_SHELL)'; cat "$$([ -e "$(_BTGT)" ] || echo "$(srcdir)/")$(_BTGT)"; } | \
41 checkbashisms -npx 2>&1 | grep -vFe "'command' with option other than -p" -e 'command -v' -e 'any possible bashisms' $(CHECKBASHISMS_IGNORE) >&2
42 else
43 @echo "skipping checkbashisms of" $(_BTGT) "because checkbashisms is not installed"
44 endif
45
46 checkbashisms: $(SHELLCHECKSCRIPTS) $(call JUST_CHECKBASHISMS_OPTS,$(SHELLCHECKSCRIPTS)) checkbashisms-recursive