-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparole.sh
82 lines (76 loc) · 1.75 KB
/
parole.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
TESTOP=$(echo $TESTO | tr '[:upper:]' '[:lower:]') #Trasforma ogni lettera maiuscola in minuscolo #per poter comparare case-insensitive
. var/stars.sh
while read WORD; do #Controlla se messaggio contiene parole vietate
case "$TESTOP" in
# match exact string
"$WORD")
VIA="N"
echo "Trovata parola o frase non accettata"
if [ "$STARS" = "S" ]; then
VIA="S"
STAR=""
LENGHT=${#WORD}
while [ "$LENGHT" != "0" ]
do
STAR="${STAR}*"
LENGHT=$((LENGHT-1))
done
TESTO=$(echo "$TESTO" | sed -e "s/$WORD/"$STAR"/g")
echo "Metto stelline!"
fi
;;
# match start of string
"$WORD"*)
VIA="N"
echo "Trovata parola o frase non accettata"
if [ "$STARS" = "S" ]; then
VIA="S"
STAR=""
LENGHT=${#WORD}
while [ "$LENGHT" != "0" ]
do
STAR="${STAR}*"
LENGHT=$((LENGHT-1))
done
TESTO=$(echo "$TESTO" | sed -e "s/$WORD/"$STAR"/g")
echo "Metto stelline!"
fi
;;
# match end of string
*"$WORD")
VIA="N"
echo "Trovata parola o frase non accettata"
if [ "$STARS" = "S" ]; then
VIA="S"
STAR=""
LENGHT=${#WORD}
while [ "$LENGHT" != "0" ]
do
STAR="${STAR}*"
LENGHT=$((LENGHT-1))
done
TESTO=$(echo "$TESTO" | sed -e "s/$WORD/"$STAR"/g")
echo "Metto stelline!"
fi
;;
# searchString can be anywhere in this String
*"$WORD"*)
VIA="N"
echo "Trovata parola o frase non accettata"
if [ "$STARS" = "S" ]; then
VIA="S"
STAR=""
LENGHT=${#WORD}
while [ "$LENGHT" != "0" ]
do
STAR="${STAR}*"
LENGHT=$((LENGHT-1))
done
TESTO=$(echo "$TESTO" | sed -e "s/$WORD/"$STAR"/g")
echo "Metto stelline!"
fi
;;
*)
;;
esac
done < parolevietate.txt