forked from weissi/matrix-arbitrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyncheck.sh
executable file
·58 lines (47 loc) · 1.24 KB
/
syncheck.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
set -e
HERE=$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)
PROG=syncheck.sh
trap bug_found ERR
function usage() {
echo "$PROG"
}
function bug_found() {
echo >&2 "ERROR: You found a bug in the $PROG script, please report"
exit 99
}
cd "$HERE"
RET=0
#file test args msg
function check() {
if grep -q $3 "$2" -- "$1"; then
echo "SYNTAX ERROR: $4 found in '$1'"
grep --color=always $3 "$2" -- "$1" | while read line; do
echo " --> $line"
done
echo
RET=1
fi
return 0
}
while read file; do
check "$file" '^.{81,}$' -EHn "line too long"
check "$file" ' $' -EHn "trailing whitespace"
check "$file" ' ' -Hn "tab found"
done < <(find . \( -name '*.h' \
-or -name '*.cpp' \
-or -name '*.c' \
-or -name '*.hs' \
-or -name '*.chs' \
-or -name '*.tex' \
-or -name '*.sh' \
\) \
-and -not \( -path './dist/*' \
-or -path './syncheck.sh' \
\) \
-type f \
)
if [ $RET -eq 0 ]; then
echo "CONGRATULATIONS, looks fine"
fi
exit $RET