mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-25 18:59:33 +03:00
8df0bde321
Change enforced shell type from `dash` to `sh` and excluded `SC2039` and `SC3043` by default. `local` keyword is accepted by all POSIX shells from practical point of view. There is no need anymore to enforce dash so `local` is accepted. Reviewed-by: George Melikov <mail@gmelikov.ru> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: szubersk <szuberskidamian@gmail.com> Closes #13020
31 lines
1.8 KiB
Plaintext
31 lines
1.8 KiB
Plaintext
.PHONY: shellcheck
|
|
shellcheck: $(SCRIPTS) $(SHELLCHECKSCRIPTS)
|
|
|
|
# ShellCheck exclusions
|
|
#
|
|
# ShellCheck can't follow non-constant source. Use a directive to specify location. [SC1090]
|
|
# Not following: a was not specified as input (see shellcheck -x). [SC1091]
|
|
# Prefer putting braces around variable references even when not strictly required. [SC2250]
|
|
# In POSIX sh, 'local' is undefined. [SC2039] # older ShellCheck versions
|
|
# In POSIX sh, 'local' is undefined. [SC3043] # newer ShellCheck versions
|
|
if HAVE_SHELLCHECK
|
|
[ -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)
|
|
else
|
|
@[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; echo "skipping shellcheck of" $(SCRIPTS) $(SHELLCHECKSCRIPTS) "because shellcheck is not installed"
|
|
endif
|
|
@set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir shellcheck; done
|
|
|
|
|
|
# command -v *is* specified by POSIX and every shell in existence supports it
|
|
.PHONY: checkbashisms
|
|
checkbashisms: $(SCRIPTS) $(SHELLCHECKSCRIPTS)
|
|
if HAVE_CHECKBASHISMS
|
|
[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; ! if [ -z "$(SHELLCHECK_SHELL)" ]; then \
|
|
checkbashisms -npx $(SCRIPTS) $(SHELLCHECKSCRIPTS); else \
|
|
for f in $(SCRIPTS) $(SHELLCHECKSCRIPTS); do echo $$f >&3; { echo '#!/bin/$(SHELLCHECK_SHELL)'; cat $$f; } | checkbashisms -npx; done; \
|
|
fi 3>&2 2>&1 | grep -vFe "'command' with option other than -p" -e 'command -v' $(CHECKBASHISMS_IGNORE) >&2
|
|
else
|
|
@[ -z "$(SCRIPTS)$(SHELLCHECKSCRIPTS)" ] && exit; echo "skipping checkbashisms of" $(SCRIPTS) $(SHELLCHECKSCRIPTS) "because checkbashisms is not installed"
|
|
endif
|
|
@set -e; for dir in $(SHELLCHECKDIRS); do $(MAKE) -C $$dir checkbashisms; done
|