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 code that expands directories only works
42 # Test quoted and unquoted globbing characters
52 expect '<c> <ca> <cb> <a*> <*q*>'
67 # Pattern from Larry Wall's Configure that caused bash to blow up
68 expect '</^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/>'
69 recho "/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/"
71 # Make sure character classes work properly
73 expect '<abc> <abd> <abe> <bb> <cb>'
76 expect '<abd> <abe> <bb> <bcd> <bdir> <ca> <cb> <dd> <de>'
87 expect '<Beware> <d> <dd> <de>'
90 # Make sure that filenames with embedded globbing characters are handled
111 *.\*) echo not there ;;
115 # examples from the Posix.2 spec (d11.2, p. 243)
130 a"b"c) echo 'match 1' ;;
131 *) echo 'BAD match 1' ;;
136 a*c) echo 'match 2' ;;
137 *) echo 'BAD match 2' ;;
142 "a?c") echo 'bad 1' ;;
148 a\*c) echo 'bad 2' ;;
154 a\[b]c) echo 'bad 3' ;;
164 # This is very odd, but sh and ksh seem to agree
167 a["\b"]c) echo 'ok 5' ;;
173 touch man/man1/bash.1
174 expect '<man/man1/bash.1>'
176 expect '<man/man1/bash.1>'
177 recho $(echo */man*/bash.*)
178 expect '<man/man1/bash.1>'
179 recho "$(echo */man*/bash.*)"
181 # tests with multiple `*'s
187 a*****?c) echo ok 2;;
191 ?*****??) echo ok 3;;
199 *****??c) echo ok 5;;
203 ?*****?c) echo ok 6;;
207 ?***?****c) echo ok 7;;
211 ?***?****?) echo ok 8;;
215 ?***?****) echo ok 9;;
219 *******c) echo ok 10;;
223 *******?) echo ok 11;;
227 a*cd**?**??k) echo ok 20;;
231 a**?**cd**?**??k) echo ok 21;;
235 a**?**cd**?**??k***) echo ok 22;;
239 a**?**cd**?**??***k) echo ok 23;;
243 a**?**cd**?**??***k**) echo ok 24;;
247 a****c**?**??*****) echo ok 25;;
251 [-abc]) echo ok 26 ;;
255 [abc-]) echo ok 27 ;;
274 # a `[' without a closing `]' is just another character to match, in the
275 # bash implementation
284 # a right bracket shall lose its special meaning and represent itself in
285 # a bracket expression if it occurs first in the list. -- POSIX.2 2.8.3.2
294 # a backslash should just escape the next character in this context
296 [a-\z]) echo ok 36 ;;
299 # this was a bug in all versions up to bash-2.04-release
301 [/\\]*) echo ok 37 ;;
304 # none of these should output anything
307 ??**********?****?) echo bad 1;;
311 ??**********?****c) echo bad 2;;
315 ?************c****?****) echo bad 3;;
323 a*****c*?**) echo bad 5;;
327 a********???*******) echo bad 6;;
338 # let's start testing the case-insensitive globbing code
347 # make sure set -f works right
352 # test out the GLOBIGNORE code
353 GLOBIGNORE='.*:*c:*e:?'
356 GLOBIGNORE='.*:*b:*d:?'
359 # see if GLOBIGNORE can substitute for `set -f'
364 expect '<man/man1/bash.1>'
367 # make sure null values for GLOBIGNORE have no effect
369 expect '<man/man1/bash.1>'
372 # this is for the benefit of pure coverage, so it writes the pcv file
373 # in the right place, and for gprof