Commit dca18c42 authored by Artur Paszkiewicz's avatar Artur Paszkiewicz Committed by Jim Harris
Browse files

scripts/check_format: speed up searching for shfmt



Listing all possible commands with compgen can be painfully slow (at
least on WSL). Limit it to show only what's needed:

> time compgen -c shfmt
shfmt_v3.8.0

real    0m0.104s
user    0m0.006s
sys     0m0.000s

> time compgen -c | grep '^shfmt'
shfmt_v3.8.0

real    0m47.193s
user    0m0.104s
sys     0m1.281s

Change-Id: I9242f610b249387d8312f5986e00a12bc1900faa
Signed-off-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@solidigm.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/25703


Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Reviewed-by: default avatarChangpeng Liu <changpeliu@tencent.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz@tzawadzki.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
parent ea1b9074
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -535,7 +535,7 @@ 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))
	shfmt_bins=($(compgen -c shfmt | uniq || true))
	for bin in "${shfmt_bins[@]}"; do
		shfmt_version=$("$bin" --version)
		if [[ $shfmt_version == "$supported_shfmt_version" ]]; then