Reformat Source: Store min version in variable
SCRIPTS_DIR=$(dirname "$0")
. "${SCRIPTS_DIR}/include-common"
-CLANG_FORMAT=$(which clang-format-6.0 || which clang-format)
+MIN_VERSION=6
+CLANG_FORMAT=$(which clang-format-$MIN_VERSION.0 || which clang-format)
if [ -n "$CLANG_FORMAT" ]; then
location="$CLANG_FORMAT"
version=$("$CLANG_FORMAT" --version 2> /dev/null)
majorVersion=$(printf '%s' "$version" | sed -E 's/.* ([6-9]+)\.[0-9].[0-9][ -].*/\1/')
- [ "$majorVersion" -ge 6 ] 2> /dev/null || unset CLANG_FORMAT
+ [ "$majorVersion" -ge $MIN_VERSION ] 2> /dev/null || unset CLANG_FORMAT
fi
if [ -z "${CLANG_FORMAT}" ]; then
printf 'ClangFormat: %s\n' "$location"
printf 'Version Info: %s\n' "$version"
printf 'Major Version: %s\n' "$majorVersion"
- echo "Please install clang-format 6, or 7"
+ echo "Please install clang-format $MIN_VERSION, or 7"
exit 1
fi
