1#!/usr/bin/env bash 2 3readonly BASEDIR=$(readlink -f $(dirname $0))/.. 4cd $BASEDIR 5 6# exit on errors 7set -e 8 9if hash astyle; then 10 echo -n "Checking coding style..." 11 rm -f astyle.log 12 touch astyle.log 13 astyle --options=.astylerc "*.c" >> astyle.log 14 astyle --options=.astylerc "*.cpp" >> astyle.log 15 astyle --options=.astylerc "*.h" >> astyle.log 16 if grep -q "^Formatted" astyle.log; then 17 echo " errors detected" 18 git diff 19 sed -i -e 's/ / /g' astyle.log 20 grep --color=auto "^Formatted.*" astyle.log 21 echo "Incorrect code style detected in one or more files." 22 echo "The files have been automatically formatted." 23 echo "Remember to add the files to your commit." 24 rm -f astyle.log 25 exit 1 26 fi 27 echo " OK" 28 rm -f astyle.log 29else 30 echo "You do not have astyle installed so your code style is not being checked!" 31 exit 0 32fi 33 34git grep -I -l -e . -z | \ 35 xargs -0 -P8 -n1 scripts/eofnl 36 37exit 0 38