#!/bin/bash if [ -z "${CLANG_FORMAT}" ]; then CLANG_FORMAT="clang-format" fi function do_clang_format() { echo "verifying '${CLANG_FORMAT} --output-replacements-xml --style=Google $@'" if ${CLANG_FORMAT} --output-replacements-xml --style=Google "$@" | grep -q ' "$tmpfile" ec=0 while read -r file; do if ! do_clang_format "$file"; then ec=255 fi done < "$tmpfile" rm -f "$tmpfile" exit "$ec"