#!./perl
-
+use strict;
+use Cwd;
my %Expect_File = (); # what we expect for $_
my %Expect_Name = (); # what we expect for $File::Find::name/fullname
my %Expect_Dir = (); # what we expect for $File::Find::dir
my $symlink_exists = eval { symlink("",""); 1 };
-my $warn_msg;
+my ($warn_msg, @files, $file);
BEGIN {
if ( $symlink_exists ) { print "1..199\n"; }
else { print "1..85\n"; }
+my $orig_dir = cwd();
+
# Uncomment this to see where File::Find is chdir'ing to. Helpful for
# debugging its little jaunts around the filesystem.
# BEGIN {
my $FastFileTests_OK = 0;
sub cleanup {
+ chdir($orig_dir);
+ my $need_updir = 0;
if (-d dir_path('for_find')) {
- chdir(dir_path('for_find'));
+ $need_updir = 1 if chdir(dir_path('for_find'));
}
if (-d dir_path('fa')) {
unlink file_path('fa', 'fa_ord'),
rmdir dir_path('fb', 'fba');
rmdir dir_path('fb');
}
- chdir(File::Spec->updir);
+ if ($need_updir) {
+ my $updir = $^O eq 'VMS' ? File::Spec::VMS->updir() : File::Spec->updir;
+ chdir($updir);
+ }
if (-d dir_path('for_find')) {
rmdir dir_path('for_find') or print "# Can't rmdir for_find: $!\n";
}
#!./perl -T
-
+use strict;
my %Expect_File = (); # what we expect for $_
my %Expect_Name = (); # what we expect for $File::Find::name/fullname
use File::Spec;
use Cwd;
+my $orig_dir = cwd();
+( my $orig_dir_untainted ) = $orig_dir =~ m|^(.+)$|; # untaint it
+
cleanup();
my $found;
my $FastFileTests_OK = 0;
sub cleanup {
+ chdir($orig_dir_untainted);
+ my $need_updir = 0;
if (-d dir_path('for_find')) {
- chdir(dir_path('for_find'));
+ $need_updir = 1 if chdir(dir_path('for_find'));
}
if (-d dir_path('fa')) {
unlink file_path('fa', 'fa_ord'),
rmdir dir_path('fb', 'fba');
rmdir dir_path('fb');
}
- chdir File::Spec->updir;
+ if ($need_updir) {
+ my $updir = $^O eq 'VMS' ? File::Spec::VMS->updir() : File::Spec->updir;
+ chdir($updir);
+ }
if (-d dir_path('for_find')) {
rmdir dir_path('for_find') or print "# Can't rmdir for_find: $!\n";
}