3 # test the shell globbing
10 # First, a test that bash-2.01.1 fails
11 ${THIS_SH} ./glob1.sub
13 MYDIR=$PWD # save where we are
15 TESTDIR=/tmp/glob-test
17 builtin cd $TESTDIR || { echo $0: cannot cd to $TESTDIR >&2 ; exit 1; }
20 touch a b c d abc abd abe bb bcd ca cb dd de Beware
23 # see if `regular' globbing works right
24 expect '<a> <abc> <abd> <abe> <X*>'
27 expect '<a> <abc> <abd> <abe>'
30 # see if null glob expansion works
33 expect '<a> <abc> <abd> <abe>'
38 # see if the failglob option works
41 touch tmp/l1 tmp/l2 tmp/l3
42 builtin echo tmp/l[12] tmp/*4 tmp/*3
44 builtin echo tmp/l[12] tmp/*4 tmp/*3
48 # see if the code that expands directories only works
52 # Test quoted and unquoted globbing characters
62 expect '<c> <ca> <cb> <a*> <*q*>'
77 # Pattern from Larry Wall's Configure that caused bash to blow up
78 expect '</^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/>'
79 recho "/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/"
81 # Make sure character classes work properly
83 expect '<abc> <abd> <abe> <bb> <cb>'
86 expect '<abd> <abe> <bb> <bcd> <bdir> <ca> <cb> <dd> <de>'
97 expect '<Beware> <d> <dd> <de>'
100 # Make sure that filenames with embedded globbing characters are handled
121 *.\*) echo not there ;;
125 # examples from the Posix.2 spec (d11.2, p. 243)
140 a"b"c) echo 'match 1' ;;
141 *) echo 'BAD match 1' ;;
146 a*c) echo 'match 2' ;;
147 *) echo 'BAD match 2' ;;
152 "a?c") echo 'bad 1' ;;
158 a\*c) echo 'bad 2' ;;
164 a\[b]c) echo 'bad 3' ;;
174 # This is very odd, but sh and ksh seem to agree
177 a["\b"]c) echo 'ok 5' ;;
183 touch man/man1/bash.1
184 expect '<man/man1/bash.1>'
186 expect '<man/man1/bash.1>'
187 recho $(echo */man*/bash.*)
188 expect '<man/man1/bash.1>'
189 recho "$(echo */man*/bash.*)"
191 # tests with multiple `*'s
197 a*****?c) echo ok 2;;
201 ?*****??) echo ok 3;;
209 *****??c) echo ok 5;;
213 ?*****?c) echo ok 6;;
217 ?***?****c) echo ok 7;;
221 ?***?****?) echo ok 8;;
225 ?***?****) echo ok 9;;
229 *******c) echo ok 10;;
233 *******?) echo ok 11;;
237 a*cd**?**??k) echo ok 20;;
241 a**?**cd**?**??k) echo ok 21;;
245 a**?**cd**?**??k***) echo ok 22;;
249 a**?**cd**?**??***k) echo ok 23;;
253 a**?**cd**?**??***k**) echo ok 24;;
257 a****c**?**??*****) echo ok 25;;
261 [-abc]) echo ok 26 ;;
265 [abc-]) echo ok 27 ;;
284 # a `[' without a closing `]' is just another character to match, in the
285 # bash implementation
294 # a right bracket shall lose its special meaning and represent itself in
295 # a bracket expression if it occurs first in the list. -- POSIX.2 2.8.3.2
304 # a backslash should just escape the next character in this context
306 [a-\z]) echo ok 36 ;;
309 # this was a bug in all versions up to bash-2.04-release
311 [/\\]*) echo ok 37 ;;
314 # none of these should output anything
317 ??**********?****?) echo bad 1;;
321 ??**********?****c) echo bad 2;;
325 ?************c****?****) echo bad 3;;
333 a*****c*?**) echo bad 5;;
337 a********???*******) echo bad 6;;
348 # let's start testing the case-insensitive globbing code
357 # make sure set -f works right
362 # test out the GLOBIGNORE code
363 GLOBIGNORE='.*:*c:*e:?'
366 GLOBIGNORE='.*:*b:*d:?'
369 # see if GLOBIGNORE can substitute for `set -f'
374 expect '<man/man1/bash.1>'
377 # make sure null values for GLOBIGNORE have no effect
379 expect '<man/man1/bash.1>'
382 # this is for the benefit of pure coverage, so it writes the pcv file
383 # in the right place, and for gprof