3 # test the shell globbing
10 MYDIR=$PWD # save where we are
12 TESTDIR=/tmp/glob-test
14 builtin cd $TESTDIR || { echo $0: cannot cd to $TESTDIR >&2 ; exit 1; }
17 touch a b c d abc abd abe bb bcd ca cb dd de
20 # see if `regular' globbing works right
21 expect '<a> <abc> <abd> <abe> <X*>'
24 expect '<a> <abc> <abd> <abe>'
27 # see if null glob expansion works
30 expect '<a> <abc> <abd> <abe>'
35 # see if the code that expands directories only works
39 # Test quoted and unquoted globbing characters
49 expect '<c> <ca> <cb> <a*> <*q*>'
64 # Pattern from Larry Wall's Configure that caused bash to blow up
65 expect '</^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/>'
66 recho "/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/"
68 # Make sure character classes work properly
70 expect '<abc> <abd> <abe> <bb> <cb>'
73 expect '<abd> <abe> <bb> <bcd> <bdir> <ca> <cb> <dd> <de>'
84 expect '<d> <dd> <de>'
87 # Make sure that filenames with embedded globbing characters are handled
108 *.\*) echo not there ;;
112 # examples from the Posix.2 spec (d11.2, p. 243)
127 a"b"c) echo 'match 1' ;;
128 *) echo 'BAD match 1' ;;
133 a*c) echo 'match 2' ;;
134 *) echo 'BAD match 2' ;;
139 "a?c") echo 'bad 1' ;;
145 a\*c) echo 'bad 2' ;;
151 a\[b]c) echo 'bad 3' ;;
161 # This is very odd, but sh and ksh seem to agree
164 a["\b"]c) echo 'ok 5' ;;
170 touch man/man1/bash.1
171 expect '<man/man1/bash.1>'
173 expect '<man/man1/bash.1>'
174 recho $(echo */man*/bash.*)
175 expect '<man/man1/bash.1>'
176 recho "$(echo */man*/bash.*)"
178 # tests with multiple `*'s
184 a*****?c) echo ok 2;;
188 ?*****??) echo ok 3;;
196 *****??c) echo ok 5;;
200 ?*****?c) echo ok 6;;
204 ?***?****c) echo ok 7;;
208 ?***?****?) echo ok 8;;
212 ?***?****) echo ok 9;;
216 *******c) echo ok 10;;
220 *******?) echo ok 11;;
224 a*cd**?**??k) echo ok 20;;
228 a**?**cd**?**??k) echo ok 21;;
232 a**?**cd**?**??k***) echo ok 22;;
236 a**?**cd**?**??***k) echo ok 23;;
240 a**?**cd**?**??***k**) echo ok 24;;
244 a****c**?**??*****) echo ok 25;;
248 [-abc]) echo ok 26 ;;
252 [abc-]) echo ok 27 ;;
271 # a `[' without a closing `]' is just another character to match, in the
272 # bash implementation
281 # a right bracket shall lose its special meaning and represent itself in
282 # a bracket expression if it occurs first in the list. -- POSIX.2 2.8.3.2
291 # none of these should output anything
294 ??**********?****?) echo bad 1;;
298 ??**********?****c) echo bad 2;;
302 ?************c****?****) echo bad 3;;
310 a*****c*?**) echo bad 5;;
314 a********???*******) echo bad 6;;
326 # make sure set -f works right
331 # test out the GLOBIGNORE code
332 GLOBIGNORE='.*:*c:*e:?'
335 GLOBIGNORE='.*:*b:*d:?'
338 # see if GLOBIGNORE can substitute for `set -f'
343 expect '<man/man1/bash.1>'
346 # make sure null values for GLOBIGNORE have no effect
348 expect '<man/man1/bash.1>'
354 # this is for the benefit of pure coverage, so it writes the pcv file