Simplify find loop in check-unicode script 62/52962/1
authorThanh Ha <thanh.ha@linuxfoundation.org>
Tue, 7 Mar 2017 15:36:02 +0000 (10:36 -0500)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Tue, 7 Mar 2017 15:37:16 +0000 (10:37 -0500)
grep prints out a list of problematic lines anyway so we don't need to
echo our own statement. This removes an unnecessary find loop and only
uses grep.

Change-Id: I7580c80620d8808b54ee9df57b2c1290ad73e26b
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
scripts/check-unicode.sh

index ab20a3ec3a640d77d4f1ee60940b2730d2463143..931c99fac8a2c9d9c38369d372bdac6a4c7e7dc8 100755 (executable)
 directory=${1:-"."}
 
 echo "Scanning $directory"
-while IFS= read -r -d '' x
-do
-    if LC_ALL=C grep -q '[^[:print:][:space:]]' "$x"; then
-        echo "file $x contains non-ascii characters"
-        exit 1
-    fi
-done < <(find "$directory" -type f -print0)
+if LC_ALL=C grep -r '[^[:print:][:space:]]' "$directory"; then
+    echo "Found files containing non-ascii characters."
+    exit 1
+fi
 
 echo "All files are ASCII only"
+