Reformat Source: Only use upper case variables
@@ -13,16 +13,16 @@ MIN_VERSION=6
CLANG_FORMAT=$(command -v clang-format-$MIN_VERSION.0 || command -v clang-format)
if [ -n "$CLANG_FORMAT" ]; then
- location="$CLANG_FORMAT"
- version=$("$CLANG_FORMAT" --version 2> /dev/null)
- majorVersion=$(printf '%s' "$version" | sed -E 's/.* ([0-9]+)\.[0-9].[0-9][ -].*/\1/')
- [ "$majorVersion" -ge $MIN_VERSION ] 2> /dev/null || unset CLANG_FORMAT
+ LOCATION="$CLANG_FORMAT"
+ VERSION=$("$CLANG_FORMAT" --version 2> /dev/null)
+ MAJOR_VERSION=$(printf '%s' "$VERSION" | sed -E 's/.* ([0-9]+)\.[0-9].[0-9][ -].*/\1/')
+ [ "$MAJOR_VERSION" -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"
+ printf 'ClangFormat: %s\n' "$LOCATION"
+ printf 'Version Info: %s\n' "$VERSION"
+ printf 'Major Version: %s\n' "$MAJOR_VERSION"
echo "Please install clang-format $MIN_VERSION, or 7"
exit 1
fi
@@ -32,6 +32,6 @@ cd "$SOURCE" || {
exit 1
}
-for file in $(find . -name '*.[ch]' -or -name '*.[ch]pp' -or -name '*.[ch].in' | grep -E -v '^./src/tools/gen'); do
- "$CLANG_FORMAT" -style=file -i "$file"
+for FILE in $(find . -name '*.[ch]' -or -name '*.[ch]pp' -or -name '*.[ch].in' | grep -E -v '^./src/tools/gen'); do
+ "$CLANG_FORMAT" -style=file -i "$FILE"
done
