Add --enable=all to ShellCheck by default

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
This commit is contained in:
Damian Szuberski 2022-02-07 20:59:09 +01:00 committed by GitHub
parent add15e9539
commit 8df0bde321
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 13 additions and 25 deletions

View File

@ -9,7 +9,6 @@ CPPCHECKDIRS += raidz_test zfs_ids_to_path zpool_influxdb
# TODO: #12084: SHELLCHECKDIRS += vdev_id
SHELLCHECKDIRS = fsck_zfs zed zpool zvol_wait
SHELLCHECK_OPTS = --enable=all
if USING_PYTHON
SUBDIRS += arcstat arc_summary dbufstat

View File

@ -5,4 +5,3 @@ dist_sbin_SCRIPTS = fsck.zfs
SUBSTFILES += $(dist_sbin_SCRIPTS)
SHELLCHECK_OPTS = --enable=all

View File

@ -5,7 +5,6 @@ AM_CFLAGS += $(LIBUDEV_CFLAGS) $(LIBUUID_CFLAGS)
SUBDIRS = zed.d
SHELLCHECKDIRS = $(SUBDIRS)
SHELLCHECK_OPTS = --enable=all
sbin_PROGRAMS = zed

View File

@ -11,8 +11,7 @@ dist_zedconf_DATA = \
zed.rc
SHELLCHECKSCRIPTS = zed-functions.sh zed.rc
SHELLCHECK_OPTS = --enable=all
SHELLCHECK_SHELL = dash
SHELLCHECK_SHELL = sh
zedexecdir = $(zfsexecdir)/zed.d

View File

@ -5,7 +5,6 @@ AM_CFLAGS += $(LIBBLKID_CFLAGS) $(LIBUUID_CFLAGS)
DEFAULT_INCLUDES += -I$(srcdir)
SHELLCHECK_OPTS = --enable=all
sbin_PROGRAMS = zpool

View File

@ -2,4 +2,3 @@ include $(top_srcdir)/config/Shellcheck.am
dist_bin_SCRIPTS = zvol_wait
SHELLCHECK_OPTS = --enable=all

View File

@ -1,7 +1,15 @@
.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 --exclude=SC1090,SC1091,SC2250 $$([ -n "$(SHELLCHECK_SHELL)" ] && echo "--shell=$(SHELLCHECK_SHELL)") $(SHELLCHECK_OPTS) $(SCRIPTS) $(SHELLCHECKSCRIPTS)
[ -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

View File

@ -10,4 +10,3 @@ endif
DIST_SUBDIRS = bash_completion.d bpftrace dracut initramfs pam_zfs_key pyzfs zcp
SHELLCHECKDIRS = bash_completion.d bpftrace dracut initramfs
SHELLCHECK_OPTS = --enable=all

View File

@ -10,4 +10,3 @@ SUBSTFILES += $(noinst_DATA)
SHELLCHECKSCRIPTS = $(noinst_DATA)
SHELLCHECK_SHELL = bash
SHELLCHECK_OPTS = --enable=all

View File

@ -5,4 +5,3 @@ EXTRA_DIST = \
zfs-trace.sh
SHELLCHECKSCRIPTS = zfs-trace.sh
SHELLCHECK_OPTS = --enable=all

View File

@ -5,5 +5,4 @@ pkgdracutdir = $(dracutdir)/modules.d/02zfsexpandknowledge
pkgdracut_SCRIPTS = \
module-setup.sh
SHELLCHECK_OPTS = --enable=all
SUBSTFILES += $(pkgdracut_SCRIPTS)

View File

@ -19,7 +19,6 @@ pkgdracut_DATA = \
zfs-rollback-bootfs.service
SUBSTFILES += $(pkgdracut_SCRIPTS) $(pkgdracut_DATA)
SHELLCHECK_OPTS = --enable=all
# Provided by /bin/sleep, and, again, every implementation of that supports this
CHECKBASHISMS_IGNORE = -e 'sleep only takes one integer' -e 'sleep 0.'

View File

@ -7,7 +7,6 @@ dist_initrd_SCRIPTS = \
SUBDIRS = conf.d conf-hooks.d hooks scripts
SHELLCHECKDIRS = hooks scripts
SHELLCHECK_OPTS = --enable=all
EXTRA_DIST = \
README.initramfs.markdown

View File

@ -7,5 +7,4 @@ hooks_SCRIPTS = \
zfs \
zfsunlock
SHELLCHECK_OPTS = --enable=all
SUBSTFILES += $(hooks_SCRIPTS)

View File

@ -9,4 +9,3 @@ SUBDIRS = local-top
SHELLCHECKDIRS = $(SUBDIRS)
SHELLCHECK_SHELL = sh
SHELLCHECK_OPTS = --enable=all

View File

@ -5,4 +5,3 @@ localtopdir = /usr/share/initramfs-tools/scripts/local-top
dist_localtop_SCRIPTS = \
zfs
SHELLCHECK_OPTS = --enable=all

View File

@ -2,7 +2,6 @@ include $(top_srcdir)/config/Shellcheck.am
SUBDIRS = zfs sudoers.d
SHELLCHECKDIRS = default $(ZFS_INIT_SYSV) zfs
SHELLCHECK_OPTS = --enable=all
if BUILD_LINUX
SUBDIRS += default $(ZFS_INIT_SYSTEMD) $(ZFS_INIT_SYSV) $(ZFS_MODULE_LOAD)

View File

@ -5,5 +5,4 @@ initconf_SCRIPTS = zfs
SUBSTFILES += $(initconf_SCRIPTS)
SHELLCHECK_SHELL = dash
SHELLCHECK_OPTS = --enable=all
SHELLCHECK_SHELL = sh

View File

@ -7,5 +7,4 @@ init_SCRIPTS = zfs-import zfs-load-key zfs-mount zfs-share zfs-zed
SUBSTFILES += $(init_SCRIPTS)
SHELLCHECK_SHELL = dash
SHELLCHECK_OPTS = --enable=all
SHELLCHECK_SHELL = sh

View File

@ -15,5 +15,4 @@ pkgsysconf_SCRIPTS = \
SUBSTFILES += $(pkgsysconf_SCRIPTS)
SHELLCHECK_OPTS = --enable=all
SHELLCHECK_SHELL = dash
SHELLCHECK_SHELL = sh

View File

@ -28,7 +28,6 @@ EXTRA_DIST = \
$(EXTRA_SCRIPTS)
SHELLCHECKSCRIPTS = $(EXTRA_SCRIPTS)
SHELLCHECK_OPTS = --enable=all
define EXTRA_ENVIRONMENT