@@ -7,13 +7,13 @@ test_description='wildmatch tests'
7
7
match () {
8
8
if test " $1 " = 1
9
9
then
10
- test_expect_success " wildmatch: match '$3 ' '$4 '" "
11
- test-wildmatch wildmatch '$3 ' '$4 '
10
+ test_expect_success " wildmatch: match '$2 ' '$3 '" "
11
+ test-wildmatch wildmatch '$2 ' '$3 '
12
12
"
13
13
elif test " $1 " = 0
14
14
then
15
- test_expect_success " wildmatch: no match '$3 ' '$4 '" "
16
- ! test-wildmatch wildmatch '$3 ' '$4 '
15
+ test_expect_success " wildmatch: no match '$2 ' '$3 '" "
16
+ ! test-wildmatch wildmatch '$2 ' '$3 '
17
17
"
18
18
else
19
19
test_expect_success " PANIC: Test framework error. Unknown matches value $1 " ' false'
@@ -53,176 +53,176 @@ pathmatch() {
53
53
}
54
54
55
55
# Basic wildmat features
56
- match 1 1 foo foo
57
- match 0 0 foo bar
58
- match 1 1 ' ' " "
59
- match 1 1 foo ' ???'
60
- match 0 0 foo ' ??'
61
- match 1 1 foo ' *'
62
- match 1 1 foo ' f*'
63
- match 0 0 foo ' *f'
64
- match 1 1 foo ' *foo*'
65
- match 1 1 foobar ' *ob*a*r*'
66
- match 1 1 aaaaaaabababab ' *ab'
67
- match 1 1 ' foo*' ' foo\*'
68
- match 0 0 foobar ' foo\*bar'
69
- match 1 1 ' f\oo' ' f\\oo'
70
- match 1 1 ball ' *[al]?'
71
- match 0 0 ten ' [ten]'
72
- match 0 1 ten ' **[!te]'
73
- match 0 0 ten ' **[!ten]'
74
- match 1 1 ten ' t[a-g]n'
75
- match 0 0 ten ' t[!a-g]n'
76
- match 1 1 ton ' t[!a-g]n'
77
- match 1 1 ton ' t[^a-g]n'
78
- match 1 x ' a]b' ' a[]]b'
79
- match 1 x a-b ' a[]-]b'
80
- match 1 x ' a]b' ' a[]-]b'
81
- match 0 x aab ' a[]-]b'
82
- match 1 x aab ' a[]a-]b'
83
- match 1 1 ' ]' ' ]'
56
+ match 1 foo foo
57
+ match 0 foo bar
58
+ match 1 ' ' " "
59
+ match 1 foo ' ???'
60
+ match 0 foo ' ??'
61
+ match 1 foo ' *'
62
+ match 1 foo ' f*'
63
+ match 0 foo ' *f'
64
+ match 1 foo ' *foo*'
65
+ match 1 foobar ' *ob*a*r*'
66
+ match 1 aaaaaaabababab ' *ab'
67
+ match 1 ' foo*' ' foo\*'
68
+ match 0 foobar ' foo\*bar'
69
+ match 1 ' f\oo' ' f\\oo'
70
+ match 1 ball ' *[al]?'
71
+ match 0 ten ' [ten]'
72
+ match 0 ten ' **[!te]'
73
+ match 0 ten ' **[!ten]'
74
+ match 1 ten ' t[a-g]n'
75
+ match 0 ten ' t[!a-g]n'
76
+ match 1 ton ' t[!a-g]n'
77
+ match 1 ton ' t[^a-g]n'
78
+ match 1 ' a]b' ' a[]]b'
79
+ match 1 a-b ' a[]-]b'
80
+ match 1 ' a]b' ' a[]-]b'
81
+ match 0 aab ' a[]-]b'
82
+ match 1 aab ' a[]a-]b'
83
+ match 1 ' ]' ' ]'
84
84
85
85
# Extended slash-matching features
86
- match 0 0 ' foo/baz/bar' ' foo*bar'
87
- match 0 0 ' foo/baz/bar' ' foo**bar'
88
- match 0 1 ' foobazbar' ' foo**bar'
89
- match 1 1 ' foo/baz/bar' ' foo/**/bar'
90
- match 1 0 ' foo/baz/bar' ' foo/**/**/bar'
91
- match 1 0 ' foo/b/a/z/bar' ' foo/**/bar'
92
- match 1 0 ' foo/b/a/z/bar' ' foo/**/**/bar'
93
- match 1 0 ' foo/bar' ' foo/**/bar'
94
- match 1 0 ' foo/bar' ' foo/**/**/bar'
95
- match 0 0 ' foo/bar' ' foo?bar'
96
- match 0 0 ' foo/bar' ' foo[/]bar'
97
- match 0 0 ' foo/bar' ' foo[^a-z]bar'
98
- match 0 0 ' foo/bar' ' f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
99
- match 1 1 ' foo-bar' ' f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
100
- match 1 0 ' foo' ' **/foo'
101
- match 1 x ' XXX/foo' ' **/foo'
102
- match 1 0 ' bar/baz/foo' ' **/foo'
103
- match 0 0 ' bar/baz/foo' ' */foo'
104
- match 0 0 ' foo/bar/baz' ' **/bar*'
105
- match 1 0 ' deep/foo/bar/baz' ' **/bar/*'
106
- match 0 0 ' deep/foo/bar/baz/' ' **/bar/*'
107
- match 1 0 ' deep/foo/bar/baz/' ' **/bar/**'
108
- match 0 0 ' deep/foo/bar' ' **/bar/*'
109
- match 1 0 ' deep/foo/bar/' ' **/bar/**'
110
- match 0 0 ' foo/bar/baz' ' **/bar**'
111
- match 1 0 ' foo/bar/baz/x' ' */bar/**'
112
- match 0 0 ' deep/foo/bar/baz/x' ' */bar/**'
113
- match 1 0 ' deep/foo/bar/baz/x' ' **/bar/*/*'
86
+ match 0 ' foo/baz/bar' ' foo*bar'
87
+ match 0 ' foo/baz/bar' ' foo**bar'
88
+ match 0 ' foobazbar' ' foo**bar'
89
+ match 1 ' foo/baz/bar' ' foo/**/bar'
90
+ match 1 ' foo/baz/bar' ' foo/**/**/bar'
91
+ match 1 ' foo/b/a/z/bar' ' foo/**/bar'
92
+ match 1 ' foo/b/a/z/bar' ' foo/**/**/bar'
93
+ match 1 ' foo/bar' ' foo/**/bar'
94
+ match 1 ' foo/bar' ' foo/**/**/bar'
95
+ match 0 ' foo/bar' ' foo?bar'
96
+ match 0 ' foo/bar' ' foo[/]bar'
97
+ match 0 ' foo/bar' ' foo[^a-z]bar'
98
+ match 0 ' foo/bar' ' f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
99
+ match 1 ' foo-bar' ' f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
100
+ match 1 ' foo' ' **/foo'
101
+ match 1 ' XXX/foo' ' **/foo'
102
+ match 1 ' bar/baz/foo' ' **/foo'
103
+ match 0 ' bar/baz/foo' ' */foo'
104
+ match 0 ' foo/bar/baz' ' **/bar*'
105
+ match 1 ' deep/foo/bar/baz' ' **/bar/*'
106
+ match 0 ' deep/foo/bar/baz/' ' **/bar/*'
107
+ match 1 ' deep/foo/bar/baz/' ' **/bar/**'
108
+ match 0 ' deep/foo/bar' ' **/bar/*'
109
+ match 1 ' deep/foo/bar/' ' **/bar/**'
110
+ match 0 ' foo/bar/baz' ' **/bar**'
111
+ match 1 ' foo/bar/baz/x' ' */bar/**'
112
+ match 0 ' deep/foo/bar/baz/x' ' */bar/**'
113
+ match 1 ' deep/foo/bar/baz/x' ' **/bar/*/*'
114
114
115
115
# Various additional tests
116
- match 0 0 ' acrt' ' a[c-c]st'
117
- match 1 1 ' acrt' ' a[c-c]rt'
118
- match 0 0 ' ]' ' [!]-]'
119
- match 1 x ' a' ' [!]-]'
120
- match 0 0 ' ' ' \'
121
- match 0 x ' \' ' \'
122
- match 0 x ' XXX/\' ' */\'
123
- match 1 x ' XXX/\' ' */\\'
124
- match 1 1 ' foo' ' foo'
125
- match 1 1 ' @foo' ' @foo'
126
- match 0 0 ' foo' ' @foo'
127
- match 1 1 ' [ab]' ' \[ab]'
128
- match 1 1 ' [ab]' ' [[]ab]'
129
- match 1 x ' [ab]' ' [[:]ab]'
130
- match 0 x ' [ab]' ' [[::]ab]'
131
- match 1 x ' [ab]' ' [[:digit]ab]'
132
- match 1 x ' [ab]' ' [\[:]ab]'
133
- match 1 1 ' ?a?b' ' \??\?b'
134
- match 1 1 ' abc' ' \a\b\c'
135
- match 0 0 ' foo' ' '
136
- match 1 0 ' foo/bar/baz/to' ' **/t[o]'
116
+ match 0 ' acrt' ' a[c-c]st'
117
+ match 1 ' acrt' ' a[c-c]rt'
118
+ match 0 ' ]' ' [!]-]'
119
+ match 1 ' a' ' [!]-]'
120
+ match 0 ' ' ' \'
121
+ match 0 ' \' ' \'
122
+ match 0 ' XXX/\' ' */\'
123
+ match 1 ' XXX/\' ' */\\'
124
+ match 1 ' foo' ' foo'
125
+ match 1 ' @foo' ' @foo'
126
+ match 0 ' foo' ' @foo'
127
+ match 1 ' [ab]' ' \[ab]'
128
+ match 1 ' [ab]' ' [[]ab]'
129
+ match 1 ' [ab]' ' [[:]ab]'
130
+ match 0 ' [ab]' ' [[::]ab]'
131
+ match 1 ' [ab]' ' [[:digit]ab]'
132
+ match 1 ' [ab]' ' [\[:]ab]'
133
+ match 1 ' ?a?b' ' \??\?b'
134
+ match 1 ' abc' ' \a\b\c'
135
+ match 0 ' foo' ' '
136
+ match 1 ' foo/bar/baz/to' ' **/t[o]'
137
137
138
138
# Character class tests
139
- match 1 x ' a1B' ' [[:alpha:]][[:digit:]][[:upper:]]'
140
- match 0 x ' a' ' [[:digit:][:upper:][:space:]]'
141
- match 1 x ' A' ' [[:digit:][:upper:][:space:]]'
142
- match 1 x ' 1' ' [[:digit:][:upper:][:space:]]'
143
- match 0 x ' 1' ' [[:digit:][:upper:][:spaci:]]'
144
- match 1 x ' ' ' [[:digit:][:upper:][:space:]]'
145
- match 0 x ' .' ' [[:digit:][:upper:][:space:]]'
146
- match 1 x ' .' ' [[:digit:][:punct:][:space:]]'
147
- match 1 x ' 5' ' [[:xdigit:]]'
148
- match 1 x ' f' ' [[:xdigit:]]'
149
- match 1 x ' D' ' [[:xdigit:]]'
150
- match 1 x ' _' ' [[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'
151
- match 1 x ' .' ' [^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'
152
- match 1 x ' 5' ' [a-c[:digit:]x-z]'
153
- match 1 x ' b' ' [a-c[:digit:]x-z]'
154
- match 1 x ' y' ' [a-c[:digit:]x-z]'
155
- match 0 x ' q' ' [a-c[:digit:]x-z]'
139
+ match 1 ' a1B' ' [[:alpha:]][[:digit:]][[:upper:]]'
140
+ match 0 ' a' ' [[:digit:][:upper:][:space:]]'
141
+ match 1 ' A' ' [[:digit:][:upper:][:space:]]'
142
+ match 1 ' 1' ' [[:digit:][:upper:][:space:]]'
143
+ match 0 ' 1' ' [[:digit:][:upper:][:spaci:]]'
144
+ match 1 ' ' ' [[:digit:][:upper:][:space:]]'
145
+ match 0 ' .' ' [[:digit:][:upper:][:space:]]'
146
+ match 1 ' .' ' [[:digit:][:punct:][:space:]]'
147
+ match 1 ' 5' ' [[:xdigit:]]'
148
+ match 1 ' f' ' [[:xdigit:]]'
149
+ match 1 ' D' ' [[:xdigit:]]'
150
+ match 1 ' _' ' [[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'
151
+ match 1 ' .' ' [^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'
152
+ match 1 ' 5' ' [a-c[:digit:]x-z]'
153
+ match 1 ' b' ' [a-c[:digit:]x-z]'
154
+ match 1 ' y' ' [a-c[:digit:]x-z]'
155
+ match 0 ' q' ' [a-c[:digit:]x-z]'
156
156
157
157
# Additional tests, including some malformed wildmats
158
- match 1 x ' ]' ' [\\-^]'
159
- match 0 0 ' [' ' [\\-^]'
160
- match 1 x ' -' ' [\-_]'
161
- match 1 x ' ]' ' [\]]'
162
- match 0 0 ' \]' ' [\]]'
163
- match 0 0 ' \' ' [\]]'
164
- match 0 0 ' ab' ' a[]b'
165
- match 0 x ' a[]b' ' a[]b'
166
- match 0 x ' ab[' ' ab['
167
- match 0 0 ' ab' ' [!'
168
- match 0 0 ' ab' ' [-'
169
- match 1 1 ' -' ' [-]'
170
- match 0 0 ' -' ' [a-'
171
- match 0 0 ' -' ' [!a-'
172
- match 1 x ' -' ' [--A]'
173
- match 1 x ' 5' ' [--A]'
174
- match 1 1 ' ' ' [ --]'
175
- match 1 1 ' $' ' [ --]'
176
- match 1 1 ' -' ' [ --]'
177
- match 0 0 ' 0' ' [ --]'
178
- match 1 x ' -' ' [---]'
179
- match 1 x ' -' ' [------]'
180
- match 0 0 ' j' ' [a-e-n]'
181
- match 1 x ' -' ' [a-e-n]'
182
- match 1 x ' a' ' [!------]'
183
- match 0 0 ' [' ' []-a]'
184
- match 1 x ' ^' ' []-a]'
185
- match 0 0 ' ^' ' [!]-a]'
186
- match 1 x ' [' ' [!]-a]'
187
- match 1 1 ' ^' ' [a^bc]'
188
- match 1 x ' -b]' ' [a-]b]'
189
- match 0 0 ' \' ' [\]'
190
- match 1 1 ' \' ' [\\]'
191
- match 0 0 ' \' ' [!\\]'
192
- match 1 1 ' G' ' [A-\\]'
193
- match 0 0 ' aaabbb' ' b*a'
194
- match 0 0 ' aabcaa' ' *ba*'
195
- match 1 1 ' ,' ' [,]'
196
- match 1 1 ' ,' ' [\\,]'
197
- match 1 1 ' \' ' [\\,]'
198
- match 1 1 ' -' ' [,-.]'
199
- match 0 0 ' +' ' [,-.]'
200
- match 0 0 ' -.]' ' [,-.]'
201
- match 1 1 ' 2' ' [\1-\3]'
202
- match 1 1 ' 3' ' [\1-\3]'
203
- match 0 0 ' 4' ' [\1-\3]'
204
- match 1 1 ' \' ' [[-\]]'
205
- match 1 1 ' [' ' [[-\]]'
206
- match 1 1 ' ]' ' [[-\]]'
207
- match 0 0 ' -' ' [[-\]]'
158
+ match 1 ' ]' ' [\\-^]'
159
+ match 0 ' [' ' [\\-^]'
160
+ match 1 ' -' ' [\-_]'
161
+ match 1 ' ]' ' [\]]'
162
+ match 0 ' \]' ' [\]]'
163
+ match 0 ' \' ' [\]]'
164
+ match 0 ' ab' ' a[]b'
165
+ match 0 ' a[]b' ' a[]b'
166
+ match 0 ' ab[' ' ab['
167
+ match 0 ' ab' ' [!'
168
+ match 0 ' ab' ' [-'
169
+ match 1 ' -' ' [-]'
170
+ match 0 ' -' ' [a-'
171
+ match 0 ' -' ' [!a-'
172
+ match 1 ' -' ' [--A]'
173
+ match 1 ' 5' ' [--A]'
174
+ match 1 ' ' ' [ --]'
175
+ match 1 ' $' ' [ --]'
176
+ match 1 ' -' ' [ --]'
177
+ match 0 ' 0' ' [ --]'
178
+ match 1 ' -' ' [---]'
179
+ match 1 ' -' ' [------]'
180
+ match 0 ' j' ' [a-e-n]'
181
+ match 1 ' -' ' [a-e-n]'
182
+ match 1 ' a' ' [!------]'
183
+ match 0 ' [' ' []-a]'
184
+ match 1 ' ^' ' []-a]'
185
+ match 0 ' ^' ' [!]-a]'
186
+ match 1 ' [' ' [!]-a]'
187
+ match 1 ' ^' ' [a^bc]'
188
+ match 1 ' -b]' ' [a-]b]'
189
+ match 0 ' \' ' [\]'
190
+ match 1 ' \' ' [\\]'
191
+ match 0 ' \' ' [!\\]'
192
+ match 1 ' G' ' [A-\\]'
193
+ match 0 ' aaabbb' ' b*a'
194
+ match 0 ' aabcaa' ' *ba*'
195
+ match 1 ' ,' ' [,]'
196
+ match 1 ' ,' ' [\\,]'
197
+ match 1 ' \' ' [\\,]'
198
+ match 1 ' -' ' [,-.]'
199
+ match 0 ' +' ' [,-.]'
200
+ match 0 ' -.]' ' [,-.]'
201
+ match 1 ' 2' ' [\1-\3]'
202
+ match 1 ' 3' ' [\1-\3]'
203
+ match 0 ' 4' ' [\1-\3]'
204
+ match 1 ' \' ' [[-\]]'
205
+ match 1 ' [' ' [[-\]]'
206
+ match 1 ' ]' ' [[-\]]'
207
+ match 0 ' -' ' [[-\]]'
208
208
209
209
# Test recursion and the abort code (use "wildtest -i" to see iteration counts)
210
- match 1 1 ' -adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' ' -*-*-*-*-*-*-12-*-*-*-m-*-*-*'
211
- match 0 0 ' -adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' ' -*-*-*-*-*-*-12-*-*-*-m-*-*-*'
212
- match 0 0 ' -adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' ' -*-*-*-*-*-*-12-*-*-*-m-*-*-*'
213
- match 1 1 ' XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' ' XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
214
- match 0 0 ' XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' ' XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
215
- match 1 0 ' abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' ' **/*a*b*g*n*t'
216
- match 0 0 ' abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' ' **/*a*b*g*n*t'
217
- match 0 x foo ' */*/*'
218
- match 0 x foo/bar ' */*/*'
219
- match 1 x foo/bba/arr ' */*/*'
220
- match 0 x foo/bb/aa/rr ' */*/*'
221
- match 1 x foo/bb/aa/rr ' **/**/**'
222
- match 1 x abcXdefXghi ' *X*i'
223
- match 0 x ab/cXd/efXg/hi ' *X*i'
224
- match 1 x ab/cXd/efXg/hi ' */*X*/*/*i'
225
- match 1 x ab/cXd/efXg/hi ' **/*X*/**/*i'
210
+ match 1 ' -adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' ' -*-*-*-*-*-*-12-*-*-*-m-*-*-*'
211
+ match 0 ' -adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' ' -*-*-*-*-*-*-12-*-*-*-m-*-*-*'
212
+ match 0 ' -adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' ' -*-*-*-*-*-*-12-*-*-*-m-*-*-*'
213
+ match 1 ' XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' ' XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
214
+ match 0 ' XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' ' XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
215
+ match 1 ' abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' ' **/*a*b*g*n*t'
216
+ match 0 ' abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' ' **/*a*b*g*n*t'
217
+ match 0 foo ' */*/*'
218
+ match 0 foo/bar ' */*/*'
219
+ match 1 foo/bba/arr ' */*/*'
220
+ match 0 foo/bb/aa/rr ' */*/*'
221
+ match 1 foo/bb/aa/rr ' **/**/**'
222
+ match 1 abcXdefXghi ' *X*i'
223
+ match 0 ab/cXd/efXg/hi ' *X*i'
224
+ match 1 ab/cXd/efXg/hi ' */*X*/*/*i'
225
+ match 1 ab/cXd/efXg/hi ' **/*X*/**/*i'
226
226
227
227
pathmatch 1 foo foo
228
228
pathmatch 0 foo fo
@@ -248,20 +248,20 @@ pathmatch 1 ab/cXd/efXg/hi '*/*X*/*/*i'
248
248
pathmatch 1 ab/cXd/efXg/hi ' *Xg*i'
249
249
250
250
# Case-sensitivity features
251
- match 0 x ' a' ' [A-Z]'
252
- match 1 x ' A' ' [A-Z]'
253
- match 0 x ' A' ' [a-z]'
254
- match 1 x ' a' ' [a-z]'
255
- match 0 x ' a' ' [[:upper:]]'
256
- match 1 x ' A' ' [[:upper:]]'
257
- match 0 x ' A' ' [[:lower:]]'
258
- match 1 x ' a' ' [[:lower:]]'
259
- match 0 x ' A' ' [B-Za]'
260
- match 1 x ' a' ' [B-Za]'
261
- match 0 x ' A' ' [B-a]'
262
- match 1 x ' a' ' [B-a]'
263
- match 0 x ' z' ' [Z-y]'
264
- match 1 x ' Z' ' [Z-y]'
251
+ match 0 ' a' ' [A-Z]'
252
+ match 1 ' A' ' [A-Z]'
253
+ match 0 ' A' ' [a-z]'
254
+ match 1 ' a' ' [a-z]'
255
+ match 0 ' a' ' [[:upper:]]'
256
+ match 1 ' A' ' [[:upper:]]'
257
+ match 0 ' A' ' [[:lower:]]'
258
+ match 1 ' a' ' [[:lower:]]'
259
+ match 0 ' A' ' [B-Za]'
260
+ match 1 ' a' ' [B-Za]'
261
+ match 0 ' A' ' [B-a]'
262
+ match 1 ' a' ' [B-a]'
263
+ match 0 ' z' ' [Z-y]'
264
+ match 1 ' Z' ' [Z-y]'
265
265
266
266
imatch 1 ' a' ' [A-Z]'
267
267
imatch 1 ' A' ' [A-Z]'
0 commit comments