]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/glob6.sub
bash-5.2 distribution sources and documentation
[thirdparty/bash.git] / tests / glob6.sub
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.
5 #
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.
10 #
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/>.
13 #
14 # tests of the backslash-in-glob-patterns discussion on the austin-group ML
15 [ $UID -eq 0 ] && { echo "glob6.sub: the test suite should not be run as root" >&2 ; }
16
17 : ${TMPDIR:=/var/tmp}
18
19 ORIG=$PWD
20 GLOBDIR=$TMPDIR/bash-glob-$$
21 mkdir $GLOBDIR || { echo "glob6.sub: cannot make directory $GLOBDIR" >&2 ; exit 1; }
22 builtin cd $GLOBDIR || { echo "glob6.sub: cannot change directory to $GLOBDIR" >&2 ; exit 1; }
23
24 # does the pattern matcher allow backslashes as escape characters and remove
25 # them as part of matching?
26 touch abcdefg
27 pat='ab\cd*'
28 printf '<%s>\n' $pat
29 pat='\.'
30 printf '<%s>\n' $pat
31 rm abcdefg
32
33 # how about when escaping pattern characters?
34 touch '*abc.c'
35 a='\**.c'
36 printf '%s\n' $a
37 rm -f '*abc.c'
38
39 # how about when making the distinction between readable and searchable path
40 # components?
41 mkdir -m a=x searchable
42 mkdir -m a=r readable
43
44 p='searchable/\.'
45 printf "%s\n" $p
46
47 p='searchable/\./.'
48 printf "%s\n" $p
49
50 p='readable/\.'
51 printf "%s\n" $p
52
53 p='readable/\./.'
54 printf "%s\n" $p
55
56 printf "%s\n" 'searchable/\.'
57 printf "%s\n" 'readable/\.'
58
59 echo */.
60
61 p='*/\.'
62 echo $p
63
64 echo */'.'
65
66 rmdir searchable readable
67
68 cd $ORIG
69 rmdir $GLOBDIR