1#!/bin/bash 2 3# The files that need to be properly formatted. We'll grow this incrementally 4# until it includes all the jemalloc source files (as we convert things over), 5# and then just replace it with 6# find -name '*.c' -o -name '*.h' -o -name '*.cpp 7FILES=( 8) 9 10if command -v clang-format &> /dev/null; then 11 CLANG_FORMAT="clang-format" 12elif command -v clang-format-8 &> /dev/null; then 13 CLANG_FORMAT="clang-format-8" 14else 15 echo "Couldn't find clang-format." 16fi 17 18if ! $CLANG_FORMAT -version | grep "version 8\." &> /dev/null; then 19 echo "clang-format is the wrong version." 20 exit 1 21fi 22 23for file in ${FILES[@]}; do 24 if ! cmp --silent $file <($CLANG_FORMAT $file) &> /dev/null; then 25 echo "Error: $file is not clang-formatted" 26 exit 1 27 fi 28done 29