diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-09-13 19:30:55 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-09-14 09:55:45 +0200 |
| commit | fab7609913c9787bdb79602ff716f5e0d1598c98 (patch) | |
| tree | 7bd1cebde179e383cbbf5868e5b664c7d0f7e88f /tools/check-whitespace.sh | |
| parent | 3f1d02b23f99beaf2bf3b06c11642e56578b12ee (diff) | |
tools/check-whitespace.sh: check for trailing whitespaces
File types that we don't format automatically can end up
with such basic untidiness as trailing whitespaces.
Check for these. Remove all existing precedents.
Diffstat (limited to 'tools/check-whitespace.sh')
| -rwxr-xr-x | tools/check-whitespace.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/check-whitespace.sh b/tools/check-whitespace.sh new file mode 100755 index 000000000..a23196601 --- /dev/null +++ b/tools/check-whitespace.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# Copyright 2020 syzkaller project authors. All rights reserved. +# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +FILES=0 +FAILED="" +RE="[[:space:]]$" +LAST_EMPTY="" +for F in $(find . -name "*.sh" -o -name "*.S" -o -name "*.py" -o -name "*.yml" -o -name "*.yaml" -o -name "*.md" | \ + egrep -v "/vendor/|/gen/"); do + ((FILES+=1)) + L=0 + while IFS= read -r LINE; do + ((L+=1)) + if [[ $LINE =~ $RE ]]; then + echo "$F:$L:1: Trailing whitespace at the end of the line. Please remove." + echo "$LINE" + FAILED="1" + fi + LAST_EMPTY="" + if [ "$LINE" == "" ]; then + LAST_EMPTY="1" + fi + done < "$F" + if [ "$LAST_EMPTY" != "" ]; then + echo "$F:$L:1: Trailing empty line at the end of the file. Please remove." + FAILED="1" + fi +done +if [ "$FAILED" != "" ]; then exit 1; fi +echo "$FILES files checked for whitespaces" |
