blob: 0b2640e9cc9e57c4b78c1ed3a09bdb8131f16d83 (
plain)
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
|
#!/bin/Shell
result=no
match hello {
he* { result=yes }
* { result=fail }
};
test "$result" = yes || echo invalid result $result for normal string match, single option && exit 1
result=no
match hello {
he* | f* { result=yes }
* { result=fail }
};
test "$result" = yes || echo invalid result $result for normal string match, multiple options && exit 1
result=no
match (well hello friends) {
(* *) { result=fail }
(* * *) { result=yes }
* { result=fail }
};
test "$result" = yes || echo invalid result $result for list match && exit 1
result=no
match yes as v {
() { result=fail }
(*) { result=yes }
* { result=$v }
};
test "$result" = yes || echo invalid result $result for match with name && exit 1
result=no
# $(...) is a list, $(echo) should be an empty list, not an empty string
match $(echo) {
* { result=fail }
() { result=yes }
};
test "$result" = yes || echo invalid result $result for list subst match && exit 1
result=no
# "$(...)" is a string, "$(echo)" should be an empty string, not an empty list
match "$(echo)" {
* { result=yes }
() { result=fail }
};
test "$result" = yes || echo invalid result $result for string subst match && exit 1
|