20 lines
440 B
Bash
Executable file
20 lines
440 B
Bash
Executable file
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
main() {
|
|
find . \( -name '*.c' -o -name '*.h' \) -type f | while read -r file; do
|
|
clang-format "$file" >"${file}.formatted" || break
|
|
|
|
if ! cmp -s "$file" "${file}.formatted"; then
|
|
mv -- "${file}.formatted" "$file"
|
|
echo "Formatted: $file"
|
|
else
|
|
rm -- "${file}.formatted"
|
|
fi
|
|
done
|
|
|
|
echo 'Formatted the whole project using clang-format'
|
|
}
|
|
|
|
main
|