1.PHONY: shellcheck 2shellcheck: $(SCRIPTS) $(SHELLCHECKSCRIPTS) 3 4# ShellCheck exclusions 5# 6# ShellCheck can't follow non-constant source. Use a directive to specify location. [SC1090] 7# Not following: a was not specified as input (see shellcheck -x). [SC1091] 8# Prefer putting braces around variable references even when not strictly required. [SC2250] 9# In POSIX sh, 'local' is undefined. [SC2039] # older ShellCheck versions 10# In POSIX sh, 'local' is undefined. [SC3043] # newer ShellCheck versions 11if HAVE_SHELLCHECK 12 [ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; shellcheck --format=gcc --enable=all --exclude=SC1090,SC1091,SC2039,SC2250,SC3043 $$([ -n "$(SHELLCHECK_SHELL)" ] && echo "--shell=$(SHELLCHECK_SHELL)") $(SHELLCHECK_OPTS) $(SCRIPTS) $(SHELLCHECKSCRIPTS) 13else 14 @[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; echo "skipping shellcheck of" $(SCRIPTS) $(SHELLCHECKSCRIPTS) "because shellcheck is not installed" 15endif 16 @set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir shellcheck; done 17 18 19# command -v *is* specified by POSIX and every shell in existence supports it 20.PHONY: checkbashisms 21checkbashisms: $(SCRIPTS) $(SHELLCHECKSCRIPTS) 22if HAVE_CHECKBASHISMS 23 [ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; ! if [ -z "$(SHELLCHECK_SHELL)" ]; then \ 24 checkbashisms -npx $(SCRIPTS) $(SHELLCHECKSCRIPTS); else \ 25 for f in $(SCRIPTS) $(SHELLCHECKSCRIPTS); do echo $$f >&3; { echo '#!/bin/$(SHELLCHECK_SHELL)'; cat $$f; } | checkbashisms -npx; done; \ 26 fi 3>&2 2>&1 | grep -vFe "'command' with option other than -p" -e 'command -v' $(CHECKBASHISMS_IGNORE) >&2 27else 28 @[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; echo "skipping checkbashisms of" $(SCRIPTS) $(SHELLCHECKSCRIPTS) "because checkbashisms is not installed" 29endif 30 @set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir checkbashisms; done 31