blob: ed9de1349c8d502f66f073617910e4ef5799b0f6 (
plain) (
blame)
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
|
case foo {
[fF][oO][oO] {}
.* {
echo 'failed foo [fF][oO][oO]'
}
}
case fOo {
[fF][oO][oO] {}
.* {
echo 'failed fOo [fF][oO][oO]'
}
}
case foo {
foo+ {}
.* {
echo 'failed foo+'
}
}
case foo {
fo+ {}
.* {
echo 'failed fo+'
}
}
case foo {
fo* {}
.* {
echo 'failed fo*'
}
}
case foo {
fo {
echo 'failed fo'
}
.* {}
}
case '[]' {
.. {}
.* {
echo 'failed [] ..'
}
}
case '[]' {
\[\] {}
.* {
echo 'failed [] \[\]'
}
}
fun match_ip {
case $1 {
([0-9][0-9]?[0-9]?)\.([0-9]?[0-9]?[0-9])\.([0-9]?[0-9]?[0-9])\.([0-9]?[0-9]?[0-9]) {
if [ $2 != yes ] {
echo "$1 should not match but it did"
}
}
.* {
if [ $2 = yes ] {
echo "$1 should match but it did not"
}
}
}
}
match_ip 192.168.1.1 yes
match_ip 999.999.999.999 yes # the IP regex is not very good but we are testing the regex engine not IP parsing.
match_ip foo no
match_ip ::1 no
match_ip 192..168.1.1 no
match_ip 192.168.1.1.1 no
match_ip 0.0.0.0 yes
match_ip 01.1.1.1 yes
match_ip 1234.0.0.1 no
|