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: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2428 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
0418ef1ef1
commit
e5f021c10e
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user