ICU-21248 Adds line ending check to Travis CI check. The eol check fits
quite well into what the script is doing already.
Note that one file, 'testrunner.cmd', contains \r, which seems to
be acceptable since it is a Windows file.
diff --git a/tools/scripts/icu-file-utf8-check.py b/tools/scripts/icu-file-utf8-check.py
index 9e30e3b..42b0693 100755
--- a/tools/scripts/icu-file-utf8-check.py
+++ b/tools/scripts/icu-file-utf8-check.py
@@ -38,14 +38,18 @@
 # all of icu/. Modify as needed.
 icu_directories_to_be_scanned = ["."]
 
+# Files that are allowed to contain \r line endings. If this list
+# grows too long consider a file instead.
+ignore_cr_in_files = [
+    "vendor/double-conversion/upstream/msvc/testrunner.cmd"
+    ]
+
 def runCommand(cmd):
     output_file = os.popen(cmd);
     output_text = output_file.read();
     exit_status = output_file.close();
-    if exit_status:
-        print('"', cmd, '" failed.  Exiting.', file=sys.stderr)
-        sys.exit(exit_status)
-    return output_text
+
+    return output_text, exit_status
 
 
 def usage():
@@ -80,6 +84,7 @@
 
 def main(argv):
     exit_status = 0
+    rc = 0
 
     try:
         opts, args = getopt.getopt(argv, "h", ("help"))
@@ -101,7 +106,10 @@
 
     for dir in icu_directories_to_be_scanned:
         print('Scanning ' + dir)
-        output = runCommand(git_cmd.replace("DIR", dir))
+        cmd = git_cmd.replace("DIR", dir)
+        output, rc = runCommand(cmd)
+        if rc:
+            print('"', cmd, '" failed. Exiting.', file=sys.stderr)
         file_list = output.splitlines()
 
         for f in file_list:
@@ -116,6 +124,15 @@
             if check_file(f, source_file) != 0:
                 exit_status = 1
 
+            # Lastly, check the line endings of the file.
+            # Note that 'grep' returns null if it reports a file,
+            # a non-null value otherwise.
+            output, rc = runCommand("grep -rPIl \"\\r\" " + f)
+            if (rc is None):
+                if f not in ignore_cr_in_files:
+                    print("File ", f, " has \\r line ending")
+                    exit_status = 1
+
     print(exit_status)
     sys.exit(exit_status)