From afc933131e546509900f1c4637c20d4b00e3d764 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Mon, 30 Dec 2024 14:51:06 -0500 Subject: [PATCH 1/3] use `grep` instead of `-regextype` to support macOS find --- etc/clang-format-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/clang-format-all.sh b/etc/clang-format-all.sh index bab3da1cd4..9e2e759140 100755 --- a/etc/clang-format-all.sh +++ b/etc/clang-format-all.sh @@ -21,7 +21,7 @@ source_dirs=( ) mapfile -t source_files < <( - find "${source_dirs[@]:?}" -regextype posix-egrep -regex '.*\.(hpp|hh|cpp)' + find "${source_dirs[@]:?}" | grep -E '.*\.(hpp|hh|cpp)$' ) if [[ -n "${DRYRUN:-}" ]]; then From 34364a851beebef036d133c884f3b19dc4587cbb Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Mon, 30 Dec 2024 14:51:38 -0500 Subject: [PATCH 2/3] allow overriding `clang-format` binary To permit non-default clang-format. --- etc/clang-format-all.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/etc/clang-format-all.sh b/etc/clang-format-all.sh index 9e2e759140..383cfa08b7 100755 --- a/etc/clang-format-all.sh +++ b/etc/clang-format-all.sh @@ -12,7 +12,8 @@ set -o errexit set -o pipefail -clang-format --version +CLANG_FORMAT="${CLANG_FORMAT:-clang-format}" +"$CLANG_FORMAT" --version source_dirs=( src @@ -25,7 +26,7 @@ mapfile -t source_files < <( ) if [[ -n "${DRYRUN:-}" ]]; then - clang-format --dry-run -Werror "${source_files[@]:?}" + "$CLANG_FORMAT" --dry-run -Werror "${source_files[@]:?}" else - clang-format --verbose -i "${source_files[@]:?}" + "$CLANG_FORMAT" --verbose -i "${source_files[@]:?}" fi From 7574e2cb689f60529172d21baaf53b876d1d082c Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Mon, 30 Dec 2024 15:36:39 -0500 Subject: [PATCH 3/3] rename variable for consistency --- etc/clang-format-all.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/etc/clang-format-all.sh b/etc/clang-format-all.sh index 383cfa08b7..e02581dae8 100755 --- a/etc/clang-format-all.sh +++ b/etc/clang-format-all.sh @@ -12,8 +12,8 @@ set -o errexit set -o pipefail -CLANG_FORMAT="${CLANG_FORMAT:-clang-format}" -"$CLANG_FORMAT" --version +clang_format_binary="${CLANG_FORMAT_BINARY:-clang-format}" +"${clang_format_binary:?}" --version source_dirs=( src @@ -26,7 +26,7 @@ mapfile -t source_files < <( ) if [[ -n "${DRYRUN:-}" ]]; then - "$CLANG_FORMAT" --dry-run -Werror "${source_files[@]:?}" + "$clang_format_binary" --dry-run -Werror "${source_files[@]:?}" else - "$CLANG_FORMAT" --verbose -i "${source_files[@]:?}" + "$clang_format_binary" --verbose -i "${source_files[@]:?}" fi