Skip to content

Commit

Permalink
Fix clang-format fallback check
Browse files Browse the repository at this point in the history
`[ -z "${CLANG_FORMAT+x}" ]` checks if CLANG_FORMAT is unset, but the
variable will be set even if `which` fails, so we have to check if it is
empty instead.
  • Loading branch information
jfblomgren authored and viferga committed Mar 24, 2021
1 parent 7fccf9f commit dd00aba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion githooks/pre-commit-clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
RECOMMENDED_CLANG_FORMAT_MAJOR="11"

CLANG_FORMAT=`which clang-format-$RECOMMENDED_CLANG_FORMAT_MAJOR 2>/dev/null`
if [ -z "${CLANG_FORMAT+x}" ]; then
if [ -z "$CLANG_FORMAT" ]; then
CLANG_FORMAT=`which clang-format 2>/dev/null`
fi

Expand Down

0 comments on commit dd00aba

Please sign in to comment.