-
Notifications
You must be signed in to change notification settings - Fork 0
/
validater.sh
33 lines (33 loc) · 1.07 KB
/
validater.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
#!/bin/bash
ls -1 | while IFS= read -r list ; do
destList="../data/${list/.list/}"
echo "Now validating list: $list"
echo "# Generated and sanitized by the Validater." > "$destList"
lineNo=0
cat "$list" | while IFS= read -r rule ; do
let lineNo=lineNo+1
if [[ "$rule" == " "* ]]; then
echo "Rule skipped due to prepended whitespace on line $lineNo."
elif [[ "$rule" == "\t"* ]]; then
echo "Rule skipped due to prepended tabs on line $lineNo."
elif [ "$rule" == "" ]; then
echo "Blank line ignored on line $lineNo."
elif [[ "$rule" == ":"* ]]; then
echo "Redundant rule ignored on line $lineNo."
elif [[ "$rule" == "#"* ]]; then
echo "Comment skipped on line $lineNo."
elif [[ "$rule" == "["* ]]; then
echo "Comment skipped on line $lineNo."
elif [[ "$rule" == "!"* ]]; then
echo "Comment skipped on line $lineNo."
elif [[ "$rule" == "||"* ]]; then
interm="${rule/||/domain:}"
echo "${interm/^/}" >> "$destList"
elif [[ "$rule" != "domain:"* ]]; then
echo "domain:$rule" >> "$destList"
else
echo "$rule" >> "$destList"
fi
done
done
exit