Commit 2e3c69d7 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

check_format: fix shfmt error message



When an unsupported shfmt version is installed on the system, while a
supported version is also installed, shell formatting will be checked
but an error message will also printed, which can be confusing.  Print
it only when no supported versions are found.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Id92f1a3d68ef63a1e1cc3f8714967aae5da6132a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23791


Reviewed-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz@tzawadzki.com>
parent 552eaa9c
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -537,13 +537,10 @@ function check_bash_style() {
	local rc=0 supported_shfmt_version=v3.8.0

	# find compatible shfmt binary
	shfmt_bins=$(compgen -c | grep '^shfmt' | uniq || true)
	for bin in $shfmt_bins; do
	shfmt_bins=($(compgen -c | grep '^shfmt' | uniq || true))
	for bin in "${shfmt_bins[@]}"; do
		shfmt_version=$("$bin" --version)
		if [[ $shfmt_version != "$supported_shfmt_version" ]]; then
			echo "$bin version $shfmt_version not used (only $supported_shfmt_version is supported)"
			echo "$supported_shfmt_version can be installed using 'scripts/pkgdep.sh -d'"
		else
		if [[ $shfmt_version == "$supported_shfmt_version" ]]; then
			shfmt=$bin
			break
		fi
@@ -602,7 +599,10 @@ function check_bash_style() {
			fi
		fi
	else
		echo "Supported version of shfmt not detected, Bash style formatting check is skipped"
		cat <<- MSG
			Supported version of shfmt not detected${shfmt_bins[*]:+ (only ${shfmt_bins[*]} is available)}.  Bash style
			formatting check is skipped.  shfmt-$supported_shfmt_version can be installed using 'scripts/pkgdep.sh -d'.
		MSG
	fi

	# Cleanup potential .orig files that shfmt creates