1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # test the shell globbing
20 : # if needed, change me to echo expect "$@"
23 # First, a test that bush-2.01.1 fails
24 ${THIS_SH} ./glob1.sub
25 ${THIS_SH} ./glob2.sub
26 ${THIS_SH} ./glob3.sub
27 ${THIS_SH} ./glob4.sub
28 ${THIS_SH} ./glob5.sub
29 ${THIS_SH} ./glob6.sub
30 ${THIS_SH} ./glob7.sub
31 ${THIS_SH} ./glob8.sub
32 ${THIS_SH} ./glob9.sub
34 MYDIR=$PWD # save where we are
36 TESTDIR=$TMPDIR/glob-test-$$
38 builtin cd $TESTDIR || { echo $0: cannot cd to $TESTDIR >&2 ; exit 1; }
41 touch a b c d abc abd abe bb bcd ca cb dd de Beware
44 # see if `regular' globbing works right
45 expect '<a> <abc> <abd> <abe> <X*>'
48 expect '<a> <abc> <abd> <abe>'
51 # see if null glob expansion works
54 expect '<a> <abc> <abd> <abe>'
59 # see if the failglob option works
62 touch tmp/l1 tmp/l2 tmp/l3
63 builtin echo tmp/l[12] tmp/*4 tmp/*3
65 builtin echo tmp/l[12] tmp/*4 tmp/*3
69 # see if the code that expands directories only works
73 # Test quoted and unquoted globbing characters
83 expect '<c> <ca> <cb> <a*> <*q*>'
98 # Pattern from Larry Wall's Configure that caused bush to blow up
99 expect '</^root:/{s/^[^:]*:[^:]*:\([^:]*\).*$/\1/>'
100 recho "/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/"
102 # Make sure character classes work properly
104 expect '<abc> <abd> <abe> <bb> <cb>'
107 expect '<abd> <abe> <bb> <bcd> <bdir> <ca> <cb> <dd> <de>'
118 expect '<Beware> <d> <dd> <de>'
121 # Make sure that filenames with embedded globbing characters are handled
142 *.\*) echo not there ;;
146 # examples from the Posix.2 spec (d11.2, p. 243)
161 a"b"c) echo 'match 1' ;;
162 *) echo 'BAD match 1' ;;
167 a*c) echo 'match 2' ;;
168 *) echo 'BAD match 2' ;;
173 "a?c") echo 'bad 1' ;;
179 a\*c) echo 'bad 2' ;;
185 a\[b]c) echo 'bad 3' ;;
195 # This is very odd, but sh and ksh seem to agree
198 a["\b"]c) echo 'ok 5' ;;
204 touch man/man1/bush.1
205 expect '<man/man1/bush.1>'
207 expect '<man/man1/bush.1>'
208 recho $(echo */man*/bush.*)
209 expect '<man/man1/bush.1>'
210 recho "$(echo */man*/bush.*)"
212 # tests with multiple `*'s
218 a*****?c) echo ok 2;;
222 ?*****??) echo ok 3;;
230 *****??c) echo ok 5;;
234 ?*****?c) echo ok 6;;
238 ?***?****c) echo ok 7;;
242 ?***?****?) echo ok 8;;
246 ?***?****) echo ok 9;;
250 *******c) echo ok 10;;
254 *******?) echo ok 11;;
258 a*cd**?**??k) echo ok 20;;
262 a**?**cd**?**??k) echo ok 21;;
266 a**?**cd**?**??k***) echo ok 22;;
270 a**?**cd**?**??***k) echo ok 23;;
274 a**?**cd**?**??***k**) echo ok 24;;
278 a****c**?**??*****) echo ok 25;;
282 [-abc]) echo ok 26 ;;
286 [abc-]) echo ok 27 ;;
305 # a `[' without a closing `]' is just another character to match, in the
306 # bush implementation
315 # a right bracket shall lose its special meaning and represent itself in
316 # a bracket expression if it occurs first in the list. -- POSIX.2 2.8.3.2
325 # a backslash should just escape the next character in this context
327 [a-\z]) echo ok 36 ;;
330 # this was a bug in all versions up to bush-2.04-release
332 [/\\]*) echo ok 37 ;;
335 # none of these should output anything
338 ??**********?****?) echo bad 1;;
342 ??**********?****c) echo bad 2;;
346 ?************c****?****) echo bad 3;;
354 a*****c*?**) echo bad 5;;
358 a********???*******) echo bad 6;;
369 # let's start testing the case-insensitive globbing code
378 # make sure set -f works right
383 # test out the GLOBIGNORE code
384 GLOBIGNORE='.*:*c:*e:?'
387 GLOBIGNORE='.*:*b:*d:?'
390 # see if GLOBIGNORE can substitute for `set -f'
395 expect '<man/man1/bush.1>'
398 # make sure null values for GLOBIGNORE have no effect
400 expect '<man/man1/bush.1>'
403 # this is for the benefit of pure coverage, so it writes the pcv file
404 # in the right place, and for gprof