Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions etc/clang-format-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
set -o errexit
set -o pipefail

clang-format --version
clang_format_binary="${CLANG_FORMAT_BINARY:-clang-format}"
"${clang_format_binary:?}" --version

source_dirs=(
src
Expand All @@ -21,11 +22,11 @@ source_dirs=(
)

mapfile -t source_files < <(
find "${source_dirs[@]:?}" -regextype posix-egrep -regex '.*\.(hpp|hh|cpp)'
find "${source_dirs[@]:?}" | grep -E '.*\.(hpp|hh|cpp)$'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I would prefer to use PCRE (-P) for consistency, IIRC it is not fully supported across all distros/versions, so I am fine with using -E here for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately -P does not appear supported on macOS grep:

% grep -P
grep: invalid option -- P
usage: grep [-abcdDEFGHhIiJLlMmnOopqRSsUVvwXxZz] [-A num] [-B num] [-C[num]]
        [-e pattern] [-f file] [--binary-files=value] [--color=when]
        [--context[=num]] [--directories=action] [--label] [--line-buffered]
        [--null] [pattern] [file ...]

)

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