util/lint: Update non-ascii linter for FreeBSD

On FreeBSD, this test was failing with the error:
"grep: Argument list too long"

- Remove support for testing coreboot not in a git repo.  Many of
the other linters already don't support this.
- Use git grep to find offending files, then xargs to print out
the lines.

Change-Id: Ic017dc3465fd9a46ff4e6ec5ef16396e963483cd
Signed-off-by: Martin Roth <martinr@coreboot.org>
Reviewed-on: https://review.coreboot.org/c/28448
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Martin Roth 2018-09-02 18:45:43 -06:00 committed by Patrick Georgi
parent 6e44d7c452
commit 300b25a910
1 changed files with 13 additions and 13 deletions

View File

@ -21,13 +21,11 @@ EXCLUDED_DIRS='^payloads/\|^src/vendorcode/\|^Documentation/\|^build/\|^3rdparty
EXCLUDED_FILES='to-wiki/towiki\.sh$\|vga/vga_font\|video/font\|PDCurses.*x11' EXCLUDED_FILES='to-wiki/towiki\.sh$\|vga/vga_font\|video/font\|PDCurses.*x11'
EXCLUDED_PHRASES='Copyright\|Ported to\|Intel®\|°C\|°F\|Athlon™\|Copyright.*©\|A-Za-zÀ-ÿ' EXCLUDED_PHRASES='Copyright\|Ported to\|Intel®\|°C\|°F\|Athlon™\|Copyright.*©\|A-Za-zÀ-ÿ'
# Use git ls-files if the code is in a git repo, otherwise use find. # Exit if git isn't present or the code isn't in a git repo
if [ -n "$(command -v git)" ] && \ if [ -z "$(command -v git)" ] || \
[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ] [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" != "true" ]
then then
FIND_FILES="git ls-files" exit
else
FIND_FILES="find . "
fi fi
# 1. Get the list of files to parse and send them through grep # 1. Get the list of files to parse and send them through grep
@ -36,10 +34,12 @@ fi
# 3. Remove common phrases and names that have been found # 3. Remove common phrases and names that have been found
# 4. Run the result through grep again to highlight the issues that were # 4. Run the result through grep again to highlight the issues that were
# found. Without this step, the characters can be difficult to see. # found. Without this step, the characters can be difficult to see.
grep -n "[^ -~]" \ # shellcheck disable=SC2046
$(${FIND_FILES} | sed 's|^\./||' | sort | \ git grep -lP "[^\t-~]" | \
grep "$INCLUDED_FILES" | \ grep "$INCLUDED_FILES" | \
grep -v "$EXCLUDED_DIRS" | \ grep -v "$EXCLUDED_DIRS" | \
grep -v "$EXCLUDED_FILES") | \ grep -v "$EXCLUDED_FILES" | \
grep -iv "$EXCLUDED_PHRASES" | \ xargs -I % \
grep --color='auto' "[^ -~]" grep -n "[^ -~]" % | \
grep -iv "$EXCLUDED_PHRASES" | \
grep --color='auto' "[^ -~]"