Add ShellCheck's `--enable=all` inside `cmd/`
The only exception is `cmd/vdev_id/vdev_id` which might be a subject of refactoring (see #12084) Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Signed-off-by: szubersk <szuberskidamian@gmail.com> Closes #12912
This commit is contained in:
parent
a8f27ec6c5
commit
c1d3be19d7
|
@ -7,8 +7,9 @@ SUBDIRS += zpool_influxdb
|
||||||
CPPCHECKDIRS = zfs zpool zdb zhack zinject zstream ztest
|
CPPCHECKDIRS = zfs zpool zdb zhack zinject zstream ztest
|
||||||
CPPCHECKDIRS += raidz_test zfs_ids_to_path zpool_influxdb
|
CPPCHECKDIRS += raidz_test zfs_ids_to_path zpool_influxdb
|
||||||
|
|
||||||
# TODO: #12084: SHELLCHECKDIRS = fsck_zfs vdev_id zpool
|
# TODO: #12084: SHELLCHECKDIRS += vdev_id
|
||||||
SHELLCHECKDIRS = fsck_zfs zpool
|
SHELLCHECKDIRS = fsck_zfs zed zpool zvol_wait
|
||||||
|
SHELLCHECK_OPTS = --enable=all
|
||||||
|
|
||||||
if USING_PYTHON
|
if USING_PYTHON
|
||||||
SUBDIRS += arcstat arc_summary dbufstat
|
SUBDIRS += arcstat arc_summary dbufstat
|
||||||
|
|
|
@ -4,3 +4,5 @@ include $(top_srcdir)/config/Shellcheck.am
|
||||||
dist_sbin_SCRIPTS = fsck.zfs
|
dist_sbin_SCRIPTS = fsck.zfs
|
||||||
|
|
||||||
SUBSTFILES += $(dist_sbin_SCRIPTS)
|
SUBSTFILES += $(dist_sbin_SCRIPTS)
|
||||||
|
|
||||||
|
SHELLCHECK_OPTS = --enable=all
|
||||||
|
|
|
@ -5,6 +5,7 @@ AM_CFLAGS += $(LIBUDEV_CFLAGS) $(LIBUUID_CFLAGS)
|
||||||
|
|
||||||
SUBDIRS = zed.d
|
SUBDIRS = zed.d
|
||||||
SHELLCHECKDIRS = $(SUBDIRS)
|
SHELLCHECKDIRS = $(SUBDIRS)
|
||||||
|
SHELLCHECK_OPTS = --enable=all
|
||||||
|
|
||||||
sbin_PROGRAMS = zed
|
sbin_PROGRAMS = zed
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,10 @@ dist_zedconf_DATA = \
|
||||||
zed-functions.sh \
|
zed-functions.sh \
|
||||||
zed.rc
|
zed.rc
|
||||||
|
|
||||||
|
SHELLCHECKSCRIPTS = zed-functions.sh zed.rc
|
||||||
|
SHELLCHECK_OPTS = --enable=all
|
||||||
|
SHELLCHECK_SHELL = dash
|
||||||
|
|
||||||
zedexecdir = $(zfsexecdir)/zed.d
|
zedexecdir = $(zfsexecdir)/zed.d
|
||||||
|
|
||||||
dist_zedexec_SCRIPTS = \
|
dist_zedexec_SCRIPTS = \
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# shellcheck disable=SC2154
|
||||||
#
|
#
|
||||||
# Log all environment variables to ZED_DEBUG_LOG.
|
# Log all environment variables to ZED_DEBUG_LOG.
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# shellcheck disable=SC2154
|
||||||
#
|
#
|
||||||
# Copyright (C) 2013-2014 Lawrence Livermore National Security, LLC.
|
# Copyright (C) 2013-2014 Lawrence Livermore National Security, LLC.
|
||||||
# Copyright (c) 2020 by Delphix. All rights reserved.
|
# Copyright (c) 2020 by Delphix. All rights reserved.
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# shellcheck disable=SC2154
|
||||||
#
|
#
|
||||||
# Send notification in response to a DATA error.
|
# Send notification in response to a DATA error.
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# shellcheck disable=SC2154
|
||||||
#
|
#
|
||||||
# Send notification in response to a given zevent.
|
# Send notification in response to a given zevent.
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# shellcheck disable=SC2154
|
||||||
#
|
#
|
||||||
# Track changes to enumerated pools for use in early-boot
|
# Track changes to enumerated pools for use in early-boot
|
||||||
set -ef
|
set -ef
|
||||||
|
@ -72,7 +73,7 @@ PROPS="name,mountpoint,canmount,atime,relatime,devices,exec\
|
||||||
,org.openzfs.systemd:wanted-by,org.openzfs.systemd:required-by\
|
,org.openzfs.systemd:wanted-by,org.openzfs.systemd:required-by\
|
||||||
,org.openzfs.systemd:nofail,org.openzfs.systemd:ignore"
|
,org.openzfs.systemd:nofail,org.openzfs.systemd:ignore"
|
||||||
|
|
||||||
"${ZFS}" list -H -t filesystem -o $PROPS -r "${ZEVENT_POOL}" > "${FSLIST_TMP}"
|
"${ZFS}" list -H -t filesystem -o "${PROPS}" -r "${ZEVENT_POOL}" > "${FSLIST_TMP}"
|
||||||
|
|
||||||
# Sort the output so that it is stable
|
# Sort the output so that it is stable
|
||||||
sort "${FSLIST_TMP}" -o "${FSLIST_TMP}"
|
sort "${FSLIST_TMP}" -o "${FSLIST_TMP}"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# shellcheck disable=SC2154
|
||||||
# resilver_finish-start-scrub.sh
|
# resilver_finish-start-scrub.sh
|
||||||
# Run a scrub after a resilver
|
# Run a scrub after a resilver
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# shellcheck disable=SC2154
|
||||||
#
|
#
|
||||||
# Send notification in response to a RESILVER_FINISH or SCRUB_FINISH.
|
# Send notification in response to a RESILVER_FINISH or SCRUB_FINISH.
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# shellcheck disable=SC2154
|
||||||
#
|
#
|
||||||
# Turn off/on vdevs' enclosure fault LEDs when their pool's state changes.
|
# Turn off/on vdevs' enclosure fault LEDs when their pool's state changes.
|
||||||
#
|
#
|
||||||
|
@ -126,6 +127,9 @@ state_to_val()
|
||||||
ONLINE)
|
ONLINE)
|
||||||
echo 0
|
echo 0
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
echo "invalid state: $state"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,26 +142,24 @@ nvme_dev_to_slot()
|
||||||
dev="$1"
|
dev="$1"
|
||||||
|
|
||||||
# Get the address "0000:01:00.0"
|
# Get the address "0000:01:00.0"
|
||||||
address=$(cat "/sys/class/block/$dev/device/address")
|
read -r address < "/sys/class/block/$dev/device/address"
|
||||||
|
|
||||||
# For each /sys/bus/pci/slots subdir that is an actual number
|
find /sys/bus/pci/slots -regex '.*/[0-9]+/address$' | \
|
||||||
# (rather than weird directories like "1-3/").
|
while read -r sys_addr; do
|
||||||
# shellcheck disable=SC2010
|
read -r this_address < "$sys_addr"
|
||||||
for i in $(ls /sys/bus/pci/slots/ | grep -E "^[0-9]+$") ; do
|
|
||||||
this_address=$(cat "/sys/bus/pci/slots/$i/address")
|
|
||||||
|
|
||||||
# The format of address is a little different between
|
# The format of address is a little different between
|
||||||
# /sys/class/block/$dev/device/address and
|
# /sys/class/block/$dev/device/address and
|
||||||
# /sys/bus/pci/slots/
|
# /sys/bus/pci/slots/
|
||||||
#
|
#
|
||||||
# address= "0000:01:00.0"
|
# address= "0000:01:00.0"
|
||||||
# this_address = "0000:01:00"
|
# this_address = "0000:01:00"
|
||||||
#
|
#
|
||||||
if echo "$address" | grep -Eq ^"$this_address" ; then
|
if echo "$address" | grep -Eq ^"$this_address" ; then
|
||||||
echo "/sys/bus/pci/slots/$i"
|
echo "${sys_addr%/*}"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# shellcheck disable=SC2154
|
||||||
#
|
#
|
||||||
# CDDL HEADER START
|
# CDDL HEADER START
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# shellcheck disable=SC2154
|
||||||
#
|
#
|
||||||
# Send notification in response to a TRIM_FINISH. The event
|
# Send notification in response to a TRIM_FINISH. The event
|
||||||
# will be received for each vdev in the pool which was trimmed.
|
# will be received for each vdev in the pool which was trimmed.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# shellcheck disable=SC2039
|
# shellcheck disable=SC2154,SC3043
|
||||||
# zed-functions.sh
|
# zed-functions.sh
|
||||||
#
|
#
|
||||||
# ZED helper functions for use in ZEDLETs
|
# ZED helper functions for use in ZEDLETs
|
||||||
|
@ -266,7 +266,7 @@ zed_notify_email()
|
||||||
| sed -e "s/@ADDRESS@/${ZED_EMAIL_ADDR}/g" \
|
| sed -e "s/@ADDRESS@/${ZED_EMAIL_ADDR}/g" \
|
||||||
-e "s/@SUBJECT@/${subject}/g")"
|
-e "s/@SUBJECT@/${subject}/g")"
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086,SC2248
|
||||||
eval ${ZED_EMAIL_PROG} ${ZED_EMAIL_OPTS} < "${pathname}" >/dev/null 2>&1
|
eval ${ZED_EMAIL_PROG} ${ZED_EMAIL_OPTS} < "${pathname}" >/dev/null 2>&1
|
||||||
rv=$?
|
rv=$?
|
||||||
if [ "${rv}" -ne 0 ]; then
|
if [ "${rv}" -ne 0 ]; then
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#
|
#
|
||||||
# This file should be owned by root and permissioned 0600.
|
# This file should be owned by root and permissioned 0600.
|
||||||
##
|
##
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
|
||||||
##
|
##
|
||||||
# Absolute path to the debug output file.
|
# Absolute path to the debug output file.
|
||||||
|
|
|
@ -5,6 +5,8 @@ AM_CFLAGS += $(LIBBLKID_CFLAGS) $(LIBUUID_CFLAGS)
|
||||||
|
|
||||||
DEFAULT_INCLUDES += -I$(srcdir)
|
DEFAULT_INCLUDES += -I$(srcdir)
|
||||||
|
|
||||||
|
SHELLCHECK_OPTS = --enable=all
|
||||||
|
|
||||||
sbin_PROGRAMS = zpool
|
sbin_PROGRAMS = zpool
|
||||||
|
|
||||||
zpool_SOURCES = \
|
zpool_SOURCES = \
|
||||||
|
|
|
@ -9,6 +9,7 @@ if [ "$1" = "-h" ] ; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# shellcheck disable=SC2154
|
||||||
dev="$VDEV_PATH"
|
dev="$VDEV_PATH"
|
||||||
|
|
||||||
# If the VDEV path is a symlink, resolve it to a real device
|
# If the VDEV path is a symlink, resolve it to a real device
|
||||||
|
|
|
@ -27,6 +27,7 @@ elif [ "$script" = "iostat-10s" ] ; then
|
||||||
brief="yes"
|
brief="yes"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# shellcheck disable=SC2154
|
||||||
if [ -f "$VDEV_UPATH" ] ; then
|
if [ -f "$VDEV_UPATH" ] ; then
|
||||||
# We're a file-based vdev, iostat doesn't work on us. Do nothing.
|
# We're a file-based vdev, iostat doesn't work on us. Do nothing.
|
||||||
exit
|
exit
|
||||||
|
@ -67,7 +68,7 @@ i=0
|
||||||
for col in $cols ; do
|
for col in $cols ; do
|
||||||
i=$((i+1))
|
i=$((i+1))
|
||||||
# Skip the first column since it's just the device name
|
# Skip the first column since it's just the device name
|
||||||
if [ $i -eq 1 ]; then
|
if [ "$i" -eq 1 ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ for i in $list ; do
|
||||||
|
|
||||||
# Special case: Looking up the size of a file-based vdev can't
|
# Special case: Looking up the size of a file-based vdev can't
|
||||||
# be done with lsblk.
|
# be done with lsblk.
|
||||||
|
# shellcheck disable=SC2154
|
||||||
if [ "$i" = "size" ] && [ -f "$VDEV_UPATH" ] ; then
|
if [ "$i" = "size" ] && [ -f "$VDEV_UPATH" ] ; then
|
||||||
size=$(du -h --apparent-size "$VDEV_UPATH" | cut -f 1)
|
size=$(du -h --apparent-size "$VDEV_UPATH" | cut -f 1)
|
||||||
echo "size=$size"
|
echo "size=$size"
|
||||||
|
|
|
@ -8,12 +8,14 @@ if [ "$1" = "-h" ] ; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# shellcheck disable=SC2154
|
||||||
if [ -b "$VDEV_UPATH" ]; then
|
if [ -b "$VDEV_UPATH" ]; then
|
||||||
device="${VDEV_UPATH##*/}"
|
device="${VDEV_UPATH##*/}"
|
||||||
read -r val 2>/dev/null < "/sys/block/$device/queue/rotational"
|
read -r val 2>/dev/null < "/sys/block/$device/queue/rotational"
|
||||||
case "$val" in
|
case "$val" in
|
||||||
0) MEDIA="ssd" ;;
|
0) MEDIA="ssd" ;;
|
||||||
1) MEDIA="hdd" ;;
|
1) MEDIA="hdd" ;;
|
||||||
|
*) MEDIA="invalid" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
vpd_pg83="/sys/block/$device/device/vpd_pg83"
|
vpd_pg83="/sys/block/$device/device/vpd_pg83"
|
||||||
|
|
|
@ -24,6 +24,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for i in $scripts ; do
|
for i in $scripts ; do
|
||||||
|
# shellcheck disable=SC2154
|
||||||
if [ -z "$VDEV_ENC_SYSFS_PATH" ] ; then
|
if [ -z "$VDEV_ENC_SYSFS_PATH" ] ; then
|
||||||
echo "$i="
|
echo "$i="
|
||||||
continue
|
continue
|
||||||
|
@ -52,7 +53,9 @@ for i in $scripts ; do
|
||||||
locate_led)
|
locate_led)
|
||||||
val=$(cat "$VDEV_ENC_SYSFS_PATH/locate" 2>/dev/null)
|
val=$(cat "$VDEV_ENC_SYSFS_PATH/locate" 2>/dev/null)
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
val=invalid
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
echo "$i=$val"
|
echo "$i=$val"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ if [ "$1" = "-h" ] ; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# shellcheck disable=SC2154
|
||||||
if [ -b "$VDEV_UPATH" ] && PATH="/usr/sbin:$PATH" command -v smartctl > /dev/null || [ -n "$samples" ] ; then
|
if [ -b "$VDEV_UPATH" ] && PATH="/usr/sbin:$PATH" command -v smartctl > /dev/null || [ -n "$samples" ] ; then
|
||||||
if [ -n "$samples" ] ; then
|
if [ -n "$samples" ] ; then
|
||||||
# cat a smartctl output text file instead of running smartctl
|
# cat a smartctl output text file instead of running smartctl
|
||||||
|
|
|
@ -4,4 +4,5 @@ if [ "$1" = "-h" ] ; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# shellcheck disable=SC2154
|
||||||
echo upath="$VDEV_UPATH"
|
echo upath="$VDEV_UPATH"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
include $(top_srcdir)/config/Shellcheck.am
|
include $(top_srcdir)/config/Shellcheck.am
|
||||||
|
|
||||||
dist_bin_SCRIPTS = zvol_wait
|
dist_bin_SCRIPTS = zvol_wait
|
||||||
|
|
||||||
|
SHELLCHECK_OPTS = --enable=all
|
||||||
|
|
Loading…
Reference in New Issue