#!/bin/bash -e usage=' dosEolnCheck kentDir Check for Git-tracked files that have MS-DOS style EOLNs (CR/LF) Arguments: o kentDir - top of kent tree; this should be the "kent" directory, NOT kent/src. ' if [ $# -ne 1 ] ; then echo "Error: wrong number of arguments" >&2 echo "$usage" >&2 exit 1 fi kentDir="$1" cd $kentDir gitFiles | awk 'NR>1{print $1}' | xargs file | awk ' /with CRLF line terminators/ { if (crlfCnt == 0) { print "Error: files tracked in Git with MS-DOS CRLF line terminators" > "/dev/stderr"; } print gensub(":","","g", $1) > "/dev/stderr"; crlfCnt++; } END { if (crlfCnt > 0) { print "Error:",crlfCnt,"files tracked in Git with MS-DOS CRLF line terminators" > "/dev/stderr"; exit(1); } } ' if [ "${PIPESTATUS[*]}" != "0 0 0 0 0" ] ; then exit 1 fi