6 require Config; import Config;
7 if ($Config{'extensions'} !~ /\bFile\/Glob\b/i) {
14 print "not ok 1\n" unless $loaded;
16 use File::Glob ':glob';
22 return '(', join(", ", map {defined $_ ? "\"$_\"" : "undef"} @a), ")\n";
25 # look for the contents of the current directory
27 delete @ENV{BASH_ENV, CDPATH, ENV, IFS};
29 if (opendir(D, ".")) {
30 @correct = grep { !/^\./ } sort readdir(D);
33 @a = File::Glob::glob("*", 0);
35 if ("@a" ne "@correct" || GLOB_ERROR) {
36 print "# |@a| ne |@correct|\nnot ";
40 # look up the user's home directory
41 # should return a list with one item, and not set ERROR
42 if ($^O ne 'MSWin32' && $^O ne 'VMS' && $^O ne 'cygwin') {
44 ($name, $home) = (getpwuid($>))[0,7];
47 @a = bsd_glob("~$name", GLOB_TILDE);
48 if (scalar(@a) != 1 || $a[0] ne $home || GLOB_ERROR) {
56 # should return a list with one item, and not set ERROR
57 @a = bsd_glob('TEST', GLOB_QUOTE);
58 if (scalar @a != 1 || $a[0] ne 'TEST' || GLOB_ERROR) {
65 # check nonexistent checks
66 # should return an empty list
67 # XXX since errfunc is NULL on win32, this test is not valid there
68 @a = bsd_glob("asdfasdf", 0);
69 if ($^O ne 'MSWin32' and scalar @a != 0) {
74 # check bad protections
75 # should return an empty list, and set ERROR
76 if ($^O eq 'mpeix' or $^O eq 'MSWin32' or $^O eq 'os2' or $^O eq 'VMS'
77 or $^O eq 'cygwin' or Cwd::cwd() =~ m#^/afs#s or not $>)
79 print "ok 6 # skipped\n";
82 $dir = "PtEeRsLt.dir";
84 @a = bsd_glob("$dir/*", GLOB_ERR);
85 #print "\@a = ", array(@a);
87 if (scalar(@a) != 0 || GLOB_ERROR == 0) {
93 # check for csh style globbing
94 @a = bsd_glob('{a,b}', GLOB_BRACE | GLOB_NOMAGIC);
95 unless (@a == 2 and $a[0] eq 'a' and $a[1] eq 'b') {
101 '{TES*,doesntexist*,a,b}',
102 GLOB_BRACE | GLOB_NOMAGIC | ($^O eq 'VMS' ? GLOB_NOCASE : 0)
105 and $a[0] eq ($^O eq 'VMS'? 'test.' : 'TEST')
113 # "~" should expand to $ENV{HOME}
114 $ENV{HOME} = "sweet home";
115 @a = bsd_glob('~', GLOB_TILDE | GLOB_NOMAGIC);
116 unless (@a == 1 and $a[0] eq $ENV{HOME}) {