Commit e5f021c1 authored by Darek Stojaczyk's avatar Darek Stojaczyk Committed by Tomasz Zawadzki
Browse files

scripts/check_format: auto-detect shfmt binary



A newer version of shfmt was released, but the script still
looked explicitly for the older one.

Make it execute the first binary '^shfmt.*' in PATH whose --version
returns at least v3.1.0.

Change-Id: If621abfa4d995a9dc985e6bab8c33aa36c327fae
Signed-off-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2428


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 0418ef1e
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -227,8 +227,16 @@ else
	echo "You do not have pycodestyle or pep8 installed so your Python style is not being checked!"
fi

shfmt="shfmt-3.1.0"
if hash "$shfmt" 2> /dev/null; then
# find compatible shfmt binary
shfmt_bins=$(compgen -c | grep '^shfmt' || true)
for bin in $shfmt_bins; do
	if [[ "$("$bin" --version)" > "v3.0.9" ]]; then
		shfmt=$bin
		break
	fi
done

if [ -n "$shfmt" ]; then
	shfmt_cmdline=() silly_plural=()

	silly_plural[1]="s"
@@ -302,7 +310,7 @@ if hash "$shfmt" 2> /dev/null; then
		fi
	fi
else
	printf '%s not detected, Bash style formatting check is skipped\n' "$shfmt"
	echo "shfmt not detected, Bash style formatting check is skipped"
fi

if hash shellcheck 2> /dev/null; then