From a69df7ea94ec244cda4c12705ad787895f97d85c Mon Sep 17 00:00:00 2001 From: Maciej Wawryk Date: Mon, 25 Nov 2019 12:44:31 +0100 Subject: [PATCH] test: Shellcheck - correct rule: Use find... Correct shellcheck rule SC2012: Use find instead of ls to better handle non-alphanumeric filenames Change-Id: Ibfc54ac06ae4cecadd22954159d259295f99912f Signed-off-by: Maciej Wawryk Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/475712 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- autobuild.sh | 2 +- scripts/check_format.sh | 2 +- test/vhost/perf_bench/vhost_perf.sh | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/autobuild.sh b/autobuild.sh index 52541f1e9..c77a1bea5 100755 --- a/autobuild.sh +++ b/autobuild.sh @@ -134,7 +134,7 @@ timing_enter make_uninstall # Create empty file to check if it is not deleted by target uninstall touch /tmp/spdk/usr/lib/sample_xyz.a $MAKE $MAKEFLAGS uninstall DESTDIR=/tmp/spdk prefix=/usr -if [[ $(ls -A /tmp/spdk/usr | wc -l) -ne 2 ]] || [[ $(ls -A /tmp/spdk/usr/lib/ | wc -l) -ne 1 ]]; then +if [[ $(find /tmp/spdk/usr -maxdepth 1 -mindepth 1 | wc -l) -ne 2 ]] || [[ $(find /tmp/spdk/usr/lib/ -maxdepth 1 -mindepth 1 | wc -l) -ne 1 ]]; then ls -lR /tmp/spdk rm -rf /tmp/spdk echo "Make uninstall failed" diff --git a/scripts/check_format.sh b/scripts/check_format.sh index 7f0e7603f..fe3bbba29 100755 --- a/scripts/check_format.sh +++ b/scripts/check_format.sh @@ -241,7 +241,7 @@ if hash shellcheck 2>/dev/null; then # Error descriptions can also be found at: https://github.com/koalaman/shellcheck/wiki # This SHCK_EXCLUDE list is out "to do" and we work to fix all of this errors. SHCK_EXCLUDE="SC1083,SC2002,\ -SC2010,SC2012,SC2016,SC2034,SC2045,SC2046,SC2086,SC2089,SC2090,\ +SC2010,SC2016,SC2034,SC2045,SC2046,SC2086,SC2089,SC2090,\ SC2097,SC2098,SC2119,SC2120" # SPDK fails some error checks which have been deprecated in later versions of shellcheck. # We will not try to fix these error checks, but instead just leave the error types here diff --git a/test/vhost/perf_bench/vhost_perf.sh b/test/vhost/perf_bench/vhost_perf.sh index fa4240c16..7044183db 100755 --- a/test/vhost/perf_bench/vhost_perf.sh +++ b/test/vhost/perf_bench/vhost_perf.sh @@ -96,7 +96,7 @@ function cleanup_split_cfg() function cleanup_parted_config() { local disks - disks=$(ls /dev/nvme*n1 | sort --version-sort) + disks=$(find /dev/ -maxdepth 1 -name 'nvme*n1' | sort --version-sort) for disk in $disks; do parted -s $disk rm 1 done @@ -226,7 +226,7 @@ if [[ "$ctrl_type" == "kernel_vhost" ]]; then # Prepare kernel vhost configuration # Below grep: match only NVMe partitions which are not "Extended" type. # For example: will match nvme0n1p15 but not nvme0n1p1 - partitions=$(ls -1 /dev/nvme* | sort --version-sort | grep -P 'p(?!1$)\d+') + partitions=$(find /dev/ -maxdepth 1 -name 'nvme*' | sort --version-sort | grep -P 'p(?!1$)\d+') backstores=() # Create block backstores for vhost kernel process