Skip to content

Commit c18573e

Browse files
committed
Improve Check EOL script.
1 parent 5cd809e commit c18573e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

jenkins.check_file_eol.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
ERRFILE=jenkins.check_eol.sh.err
55
ERRFILETEMP=$ERRFILE.0
66

7+
# display a helpful message for someone reading the log
8+
echo "Check EOL > Checking $1"
9+
710
if [ ! -e $1 ]; then # the file wasn't present; not necessarily an error
811
echo "WARNING: file not found: $1"
12+
exit 0 # don't report an error but don't run the rest of this file
913
fi
1014

1115
# We can't rely on dos2unix being installed, so simply grep for the CR octet 0x0d via xxd.
@@ -21,9 +25,10 @@ if [ $? -eq 0 ]; then # grep found matches ($?==0), so we found CR (0x0d) in the
2125
echo "Displaying first 10 lines of hex dump where CR (0x0d) was found:" >> $ERRFILE
2226
xxd -g 1 $1 | grep -n '0d ' > $ERRFILETEMP
2327
head -n 10 $ERRFILETEMP >> $ERRFILE
28+
2429
# To help the user, display how many lines of hex output actually contained CR.
25-
echo "Total hex dump lines containing CR (0x0d):" >> $ERRFILE
26-
wc -l $ERRFILETEMP >> $ERRFILE
30+
LINECOUNT=`python -c "file=open('$ERRFILETEMP', 'r'); print len(file.readlines())"`
31+
echo "Total hex dump lines containing CR (0x0d): $LINECOUNT" >> $ERRFILE
2732
echo "--------------" >> $ERRFILE # same length as '--- ERRORS ---'
2833
fi
2934

0 commit comments

Comments
 (0)