xref: /freebsd/sys/contrib/openzfs/config/Shellcheck.am (revision 681ce946f33e75c590e97c53076e86dff1fe8f4a)
1.PHONY: shellcheck
2shellcheck: $(SCRIPTS) $(SHELLCHECKSCRIPTS)
3if HAVE_SHELLCHECK
4	[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; shellcheck --format=gcc --exclude=SC1090,SC1091,SC2250 $$([ -n "$(SHELLCHECK_SHELL)" ] && echo "--shell=$(SHELLCHECK_SHELL)") $(SHELLCHECK_OPTS) $(SCRIPTS) $(SHELLCHECKSCRIPTS)
5else
6	@[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; echo "skipping shellcheck of" $(SCRIPTS) $(SHELLCHECKSCRIPTS) "because shellcheck is not installed"
7endif
8	@set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir shellcheck; done
9
10
11# command -v *is* specified by POSIX and every shell in existence supports it
12.PHONY: checkbashisms
13checkbashisms: $(SCRIPTS) $(SHELLCHECKSCRIPTS)
14if HAVE_CHECKBASHISMS
15	[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; ! if [ -z "$(SHELLCHECK_SHELL)" ]; then \
16	    checkbashisms -npx $(SCRIPTS) $(SHELLCHECKSCRIPTS); else \
17	    for f in $(SCRIPTS) $(SHELLCHECKSCRIPTS); do echo $$f >&3; { echo '#!/bin/$(SHELLCHECK_SHELL)'; cat $$f; } | checkbashisms -npx; done; \
18	fi 3>&2 2>&1 | grep -vFe "'command' with option other than -p" -e 'command -v' $(CHECKBASHISMS_IGNORE) >&2
19else
20	@[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; echo "skipping checkbashisms of" $(SCRIPTS) $(SHELLCHECKSCRIPTS) "because checkbashisms is not installed"
21endif
22	@set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir checkbashisms; done
23