Skip to content

Commit c81d281

Browse files
authored
CXX-3198 support clang-format-all.sh on macOS (#1307)
* use `grep` instead of `-regextype` to support macOS find * allow overriding `clang-format` binary
1 parent f1ad6b6 commit c81d281

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

etc/clang-format-all.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
set -o errexit
1313
set -o pipefail
1414

15-
clang-format --version
15+
clang_format_binary="${CLANG_FORMAT_BINARY:-clang-format}"
16+
"${clang_format_binary:?}" --version
1617

1718
source_dirs=(
1819
src
@@ -21,11 +22,11 @@ source_dirs=(
2122
)
2223

2324
mapfile -t source_files < <(
24-
find "${source_dirs[@]:?}" -regextype posix-egrep -regex '.*\.(hpp|hh|cpp)'
25+
find "${source_dirs[@]:?}" | grep -E '.*\.(hpp|hh|cpp)$'
2526
)
2627

2728
if [[ -n "${DRYRUN:-}" ]]; then
28-
clang-format --dry-run -Werror "${source_files[@]:?}"
29+
"$clang_format_binary" --dry-run -Werror "${source_files[@]:?}"
2930
else
30-
clang-format --verbose -i "${source_files[@]:?}"
31+
"$clang_format_binary" --verbose -i "${source_files[@]:?}"
3132
fi

0 commit comments

Comments
 (0)