From bf6ca0a6313ad09f4b98f774069693c1b36ecc60 Mon Sep 17 00:00:00 2001 From: bunder2015 Date: Mon, 4 Feb 2019 12:07:19 -0500 Subject: [PATCH] shellcheck pass note: which is non-standard. Use builtin 'command -v' instead. [SC2230] note: Use -n instead of ! -z. [SC2236] Reviewed-by: George Melikov Reviewed-by: Giuseppe Di Natale Reviewed-by: Brian Behlendorf Signed-off-by: bunder2015 Closes #8367 --- cmd/zed/zed.d/statechange-led.sh | 2 +- cmd/zed/zed.d/zed-functions.sh | 2 +- cmd/zpool/zpool.d/smart | 6 +++--- scripts/zimport.sh | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/zed/zed.d/statechange-led.sh b/cmd/zed/zed.d/statechange-led.sh index c1a1bd92d..6484b7959 100755 --- a/cmd/zed/zed.d/statechange-led.sh +++ b/cmd/zed/zed.d/statechange-led.sh @@ -165,7 +165,7 @@ process_pool() fi } -if [ ! -z "$ZEVENT_VDEV_ENC_SYSFS_PATH" ] && [ ! -z "$ZEVENT_VDEV_STATE_STR" ] ; then +if [ -n "$ZEVENT_VDEV_ENC_SYSFS_PATH" ] && [ -n "$ZEVENT_VDEV_STATE_STR" ] ; then # Got a statechange for an individual VDEV val=$(state_to_val "$ZEVENT_VDEV_STATE_STR") vdev=$(basename "$ZEVENT_VDEV_PATH") diff --git a/cmd/zed/zed.d/zed-functions.sh b/cmd/zed/zed.d/zed-functions.sh index fb16e9d36..a6e608573 100644 --- a/cmd/zed/zed.d/zed-functions.sh +++ b/cmd/zed/zed.d/zed-functions.sh @@ -434,7 +434,7 @@ zed_guid_to_pool() fi guid=$(printf "%llu" "$1") - if [ ! -z "$guid" ] ; then + if [ -n "$guid" ] ; then $ZPOOL get -H -ovalue,name guid | awk '$1=='"$guid"' {print $2}' fi } diff --git a/cmd/zpool/zpool.d/smart b/cmd/zpool/zpool.d/smart index 64b5f6e4e..bd18e9d04 100755 --- a/cmd/zpool/zpool.d/smart +++ b/cmd/zpool/zpool.d/smart @@ -69,7 +69,7 @@ if [ "$1" = "-h" ] ; then exit fi -smartctl_path=$(which smartctl) +smartctl_path=$(command -v smartctl) if [ -b "$VDEV_UPATH" ] && [ -x "$smartctl_path" ] || [ -n "$samples" ] ; then if [ -n "$samples" ] ; then @@ -228,7 +228,7 @@ smart_test) esac with_vals=$(echo "$out" | grep -E "$scripts") -if [ ! -z "$with_vals" ]; then +if [ -n "$with_vals" ]; then echo "$with_vals" without_vals=$(echo "$scripts" | tr "|" "\n" | grep -v -E "$(echo "$with_vals" | @@ -237,6 +237,6 @@ else without_vals=$(echo "$scripts" | tr "|" "\n" | awk '{print $0"="}') fi -if [ ! -z "$without_vals" ]; then +if [ -n "$without_vals" ]; then echo "$without_vals" fi diff --git a/scripts/zimport.sh b/scripts/zimport.sh index 426c329c9..d7e82fe9f 100755 --- a/scripts/zimport.sh +++ b/scripts/zimport.sh @@ -233,8 +233,8 @@ src_set_vars() { ZFS_URL="$REPO/zfs/tarball/$ZFS_TAG" if [ "$TAG" = "installed" ]; then - ZPOOL_CMD=$(which zpool) - ZFS_CMD=$(which zfs) + ZPOOL_CMD=$(command -v zpool) + ZFS_CMD=$(command -v zfs) ZFS_SH="/usr/share/zfs/zfs.sh" else ZPOOL_CMD="./cmd/zpool/zpool"