1 |
#! /bin/sh |
2 |
|
3 |
#================================================================ |
4 |
# tabcheck |
5 |
# Find files including dispensable tab and space characters |
6 |
#================================================================ |
7 |
|
8 |
|
9 |
# set variables |
10 |
LANG=C ; export LANG |
11 |
LC_ALL=C ; export LC_ALL |
12 |
regex='(\.h|\.c|\.cc|\.cpp|\.cxx|\.java|\.pl|\.pm|\.pod|\.rb|\.rd)$' |
13 |
tabcode=`printf '\t'` |
14 |
|
15 |
|
16 |
# find tab |
17 |
find . -type f | egrep $regex | |
18 |
while read file |
19 |
do |
20 |
printf 'Checking %s ... ' $file |
21 |
err=0 |
22 |
if grep "$tabcode" $file > /dev/null |
23 |
then |
24 |
printf '### !!! TAB FOUND !!! ###' |
25 |
err=1 |
26 |
fi |
27 |
if grep ' $' $file > /dev/null |
28 |
then |
29 |
printf '### !!! TAILING SPACE FOUND !!! ###' |
30 |
err=1 |
31 |
fi |
32 |
[ "$err" = 0 ] && printf 'ok' |
33 |
printf '\n' |
34 |
done |
35 |
|
36 |
|
37 |
# exit normally |
38 |
exit 0 |
39 |
|
40 |
|
41 |
|
42 |
# END OF FILE |