Include actual count of files with CRLF endings found

The script has been updated to include the actual count of files
with CRLF endings found.

The exit status of the script now accurately reflects the number of
files with incorrect line endings.
This commit is contained in:
Emmanuel Chee-zaram Okeke
2023-06-22 02:41:20 +01:00
committed by Daniel Martí
parent d3763143bd
commit 47296634f1
2 changed files with 15 additions and 15 deletions

View File

@@ -8,8 +8,9 @@
Andrew LeFevre <jalefevre@liberty.edu>
Daniel Martí <mvdan@mvdan.cc>
Emmanuel Chee-zaram Okeke <ecokeke21@gmail.com>
Nicholas Jones <me@nicholasjon.es>
Zachary Wasserman <zachwass2000@gmail.com>
lu4p <lu4p@pm.me>
pagran <pagran@protonmail.com>
shellhazard <shellhazard@tutanota.com>
shellhazard <shellhazard@tutanota.com>

View File

@@ -1,19 +1,18 @@
#!/bin/bash
if
grep \
--recursive \
--files-with-matches \
--binary \
--binary-files=without-match \
--max-count=1 \
--exclude-dir="\.git" \
$'\r' \
.
then
# TODO exit status should be number of files with wrong endings found
echo -e "Found at least a file with CRLF endings."
exit 1
file_count=$(grep \
--recursive \
--files-with-matches \
--binary \
--binary-files=without-match \
--max-count=1 \
--exclude-dir="\.git" \
$'\r' \
. | wc -l)
if [[ $file_count -gt 0 ]]; then
echo -e "Found $file_count file(s) with CRLF endings."
exit "$file_count"
fi
echo -e "No files with CRLF endings found."