Skip to content

Commit

Permalink
Add --enable=all to ShellCheck by default
Browse files Browse the repository at this point in the history
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
  • Loading branch information
szubersk authored Feb 7, 2022
1 parent add15e9 commit 8df0bde
Show file tree
Hide file tree
Showing 21 changed files with 13 additions and 25 deletions.
1 change: 0 additions & 1 deletion cmd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion cmd/fsck_zfs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ dist_sbin_SCRIPTS = fsck.zfs

SUBSTFILES += $(dist_sbin_SCRIPTS)

SHELLCHECK_OPTS = --enable=all
1 change: 0 additions & 1 deletion cmd/zed/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ AM_CFLAGS += $(LIBUDEV_CFLAGS) $(LIBUUID_CFLAGS)

SUBDIRS = zed.d
SHELLCHECKDIRS = $(SUBDIRS)
SHELLCHECK_OPTS = --enable=all

sbin_PROGRAMS = zed

Expand Down
3 changes: 1 addition & 2 deletions cmd/zed/zed.d/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion cmd/zpool/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ AM_CFLAGS += $(LIBBLKID_CFLAGS) $(LIBUUID_CFLAGS)

DEFAULT_INCLUDES += -I$(srcdir)

SHELLCHECK_OPTS = --enable=all

sbin_PROGRAMS = zpool

Expand Down
1 change: 0 additions & 1 deletion cmd/zvol_wait/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ include $(top_srcdir)/config/Shellcheck.am

dist_bin_SCRIPTS = zvol_wait

SHELLCHECK_OPTS = --enable=all
10 changes: 9 additions & 1 deletion config/Shellcheck.am
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion contrib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion contrib/bash_completion.d/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ SUBSTFILES += $(noinst_DATA)

SHELLCHECKSCRIPTS = $(noinst_DATA)
SHELLCHECK_SHELL = bash
SHELLCHECK_OPTS = --enable=all
1 change: 0 additions & 1 deletion contrib/bpftrace/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ EXTRA_DIST = \
zfs-trace.sh

SHELLCHECKSCRIPTS = zfs-trace.sh
SHELLCHECK_OPTS = --enable=all
1 change: 0 additions & 1 deletion contrib/dracut/02zfsexpandknowledge/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ pkgdracutdir = $(dracutdir)/modules.d/02zfsexpandknowledge
pkgdracut_SCRIPTS = \
module-setup.sh

SHELLCHECK_OPTS = --enable=all
SUBSTFILES += $(pkgdracut_SCRIPTS)
1 change: 0 additions & 1 deletion contrib/dracut/90zfs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
1 change: 0 additions & 1 deletion contrib/initramfs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion contrib/initramfs/hooks/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ hooks_SCRIPTS = \
zfs \
zfsunlock

SHELLCHECK_OPTS = --enable=all
SUBSTFILES += $(hooks_SCRIPTS)
1 change: 0 additions & 1 deletion contrib/initramfs/scripts/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ SUBDIRS = local-top

SHELLCHECKDIRS = $(SUBDIRS)
SHELLCHECK_SHELL = sh
SHELLCHECK_OPTS = --enable=all
1 change: 0 additions & 1 deletion contrib/initramfs/scripts/local-top/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ localtopdir = /usr/share/initramfs-tools/scripts/local-top
dist_localtop_SCRIPTS = \
zfs

SHELLCHECK_OPTS = --enable=all
1 change: 0 additions & 1 deletion etc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions etc/default/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ initconf_SCRIPTS = zfs

SUBSTFILES += $(initconf_SCRIPTS)

SHELLCHECK_SHELL = dash
SHELLCHECK_OPTS = --enable=all
SHELLCHECK_SHELL = sh
3 changes: 1 addition & 2 deletions etc/init.d/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions etc/zfs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ pkgsysconf_SCRIPTS = \

SUBSTFILES += $(pkgsysconf_SCRIPTS)

SHELLCHECK_OPTS = --enable=all
SHELLCHECK_SHELL = dash
SHELLCHECK_SHELL = sh
1 change: 0 additions & 1 deletion scripts/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ EXTRA_DIST = \
$(EXTRA_SCRIPTS)

SHELLCHECKSCRIPTS = $(EXTRA_SCRIPTS)
SHELLCHECK_OPTS = --enable=all

define EXTRA_ENVIRONMENT

Expand Down

0 comments on commit 8df0bde

Please sign in to comment.