Salome HOME
renamed and updated test script to avoid random failures on Windows
[modules/shaper.git] / findDOSfiles.sh
1 #!/bin/bash
2
3 function isDOSFile
4 {
5   local FILENAME="$1" 
6   file "$FILENAME" | grep -q "CRLF line terminators" 
7 }
8
9 if git-rev-parse --verify HEAD >/dev/null 2>&1 ; then
10   against=HEAD
11 else
12   # Initial commit: diff against an empty tree object
13   against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
14 fi
15
16 # Find files with DOS line endings
17 FOUND=0
18 for FILE in $(exec git diff-index --check --cached $against -- | sed '/^[+-]/d' | sed -r 's/:[0-9]+:.*//' | uniq) ; do
19     isDOSFile "$FILE" 
20     if (( $? == 0 ))
21     then
22       echo "\"$FILE\" has DOS line endings" >&2
23       FOUND=1
24     fi
25 done
26
27 exit $FOUND