-
Notifications
You must be signed in to change notification settings - Fork 0
/
myLint.sh
141 lines (122 loc) · 3.53 KB
/
myLint.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/sh
### $Id: $
### Script to parse other script for missing component of pairings.
parseIt5()
{
TMP=/tmp/$LOGNAME.$P.$$
{
cat <<-!EOF
fs1=\' ;
n=split($0,p,fs1) ;
if ( n == 2 ) {
printf("%6s %s: %s\n", NR, n, $0);
}
if ( n == 4 ) {
printf("%6s %s: %s\n", NR, n, $0);
}
if ( n == 6 ) {
printf("%6s %s: %s\n", NR, n, $0);
}
if ( n == 8 ) {
printf("%6s %s: %s\n", NR, n, $0);
}
!EOF
} >$TMP
cat $TMP
awk -f $TMP
}
parseIt1()
{
awk -v fs1="{" -v fs2="}" '{
n1=split($0,p,fs1);
n2=split($0,p,fs2);
if ( n1 != n2 ) {
printf("%6s %s: %s\n", NR, n, $0)
}
}'
}
parseIt2()
{
awk -v fs1="(" -v fs2=")" '{
n1=split($0,p,fs1);
n2=split($0,p,fs2);
if ( n1 != n2 ) {
printf("%6s %s: %s\n", NR, n, $0)
}
}'
}
parseIt3()
{
awk -v fs1="\"" '{
n=split($0,p,fs1);
if ( (n == 2) || (n == 4) || (n == 6) || (n == 8) || (n == 10) || (n == 12) ) {
printf("%6s %s: %s\n", NR, n, $0)
}
}'
}
parseIt4()
{
awk -v fs1="\`" '{
n=split($0,p,fs1);
if ( (n == 2) || (n == 4) || (n == 6) || (n == 8) || (n == 10) || (n == 12) ) {
printf("%6s %s: %s\n", NR, n, $0)
}
}'
}
parseIt6()
{
awk -v fs1="'" '{
n=split($0,p,fs1);
if ( (n == 2) || (n == 4) || (n == 6) || (n == 8) || (n == 10) || (n == 12) ) {
printf("%6s %s: %s\n", NR, n, $0)
}
}'
}
batchIt=0
if [ $# -ne 0 ]
then
while [ true ]
do
case $1 in
--batch ) batchIt=1 ; shift ;;
* ) break ;;
esac
done
for file in $*
do
if [ ${batchIt} -eq 1 ] ; then
echo "\n########################################################################################################"
echo "########################################################################################################"
echo " FILE: ${file} ..."
else
echo "\n FILE: ${file} ..."
fi
echo "\n-----------------------------------------------------------------------------------------------\n Phase I - checking braces ..."
cat $file |
parseIt1
if [ ${batchIt} -eq 0 ] ; then echo "\n Hit return to continue ...\c" ; read k ; fi
echo "\n-----------------------------------------------------------------------------------------------\n Phase II - checking brackets ..."
cat $file |
parseIt2
if [ ${batchIt} -eq 0 ] ; then echo "\n Hit return to continue ...\c" ; read k ; fi
echo "\n-----------------------------------------------------------------------------------------------\n Phase III - checking double-quotes ..."
cat $file |
parseIt3
if [ ${batchIt} -eq 0 ] ; then echo "\n Hit return to continue ...\c" ; read k ; fi
echo "\n-----------------------------------------------------------------------------------------------\n Phase IV - checking back-quotes ..."
cat $file |
parseIt4
if [ ${batchIt} -eq 0 ] ; then echo "\n Hit return to continue ...\c" ; read k ; fi
echo "\n-----------------------------------------------------------------------------------------------\n Phase VI - checking single-quotes ..."
cat $file |
parseIt6
if [ ${batchIt} -eq 0 ] ; then echo "\n Hit return to continue ...\c" ; read k ; fi
done
echo "\n Done!\n"
else
cat |
parseIt
fi
exit 0
exit 0
exit 0