lib/ExtUtils/t/basic.t See if MakeMaker can build a module
lib/ExtUtils/t/build_man.t Set if MakeMaker builds manpages
lib/ExtUtils/t/bytes.t Test ExtUtils::MakeMaker::bytes
-lib/ExtUtils/t/Command.t See if ExtUtils::Command works (Win32 only)
lib/ExtUtils/t/config.t Test ExtUtils::MakeMaker::Config
lib/ExtUtils/t/Constant.t See if ExtUtils::Constant works
lib/ExtUtils/t/dir_target.t Verify if dir_target() is supported
lib/ExtUtils/t/Embed.t See if ExtUtils::Embed and embedding works
+lib/ExtUtils/t/eu_command.t See if ExtUtils::Command works
lib/ExtUtils/testlib.pm Fixes up @INC to use just-built extension
lib/ExtUtils/t/FIRST_MAKEFILE.t See if FIRST_MAKEFILE works
lib/ExtUtils/t/hints.t See if hint files are honored.
require Exporter;
use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION);
@ISA = qw(Exporter);
-@EXPORT = qw(cp rm_f rm_rf mv cat eqtime mkpath touch test_f chmod
+@EXPORT = qw(cp rm_f rm_rf mv cat eqtime mkpath touch test_f test_d chmod
dos2unix);
-$VERSION = '1.09';
+$VERSION = '1.11';
my $Is_VMS = $^O eq 'VMS';
=head1 SYNOPSIS
- perl -MExtUtils::Command -e cat files... > destination
- perl -MExtUtils::Command -e mv source... destination
- perl -MExtUtils::Command -e cp source... destination
- perl -MExtUtils::Command -e touch files...
- perl -MExtUtils::Command -e rm_f files...
- perl -MExtUtils::Command -e rm_rf directories...
- perl -MExtUtils::Command -e mkpath directories...
- perl -MExtUtils::Command -e eqtime source destination
- perl -MExtUtils::Command -e test_f file
- perl -MExtUtils::Command -e chmod mode files...
+ perl -MExtUtils::Command -e cat files... > destination
+ perl -MExtUtils::Command -e mv source... destination
+ perl -MExtUtils::Command -e cp source... destination
+ perl -MExtUtils::Command -e touch files...
+ perl -MExtUtils::Command -e rm_f files...
+ perl -MExtUtils::Command -e rm_rf directories...
+ perl -MExtUtils::Command -e mkpath directories...
+ perl -MExtUtils::Command -e eqtime source destination
+ perl -MExtUtils::Command -e test_f file
+ perl -MExtUtils::Command -e test_d directory
+ perl -MExtUtils::Command -e chmod mode files...
...
=head1 DESCRIPTION
perl -MExtUtils::Command -e 'some_command qw(some files to work on)'
-For that use L<Shell::Command>.
-
Filenames with * and ? will be glob expanded.
=over 4
}
-=item cat
-
- cat file ...
+=item cat
Concatenates all files mentioned on command line to STDOUT.
print while (<>);
}
-=item eqtime
-
- eqtime source destination
+=item eqtime src dst
-Sets modified time of destination to that of source.
+Sets modified time of dst to that of src
=cut
utime((stat($src))[8,9],$dst);
}
-=item rm_rf
+=item rm_rf files....
- rm_rf files or directories ...
-
-Removes files and directories - recursively (even if readonly)
+Removes directories - recursively (even if readonly)
=cut
rmtree([grep -e $_,@ARGV],0,0);
}
-=item rm_f
-
- rm_f file ...
+=item rm_f files....
Removes files (even if readonly)
chmod(0777, $file);
next if _unlink($file);
-
+
carp "Cannot delete $file: $!";
}
}
}
-=item touch
-
- touch file ...
+=item touch files ...
Makes files exist, with current timestamp
}
}
-=item mv
-
- mv source_file destination_file
- mv source_file source_file destination_dir
+=item mv source... destination
Moves source to destination. Multiple sources are allowed if
destination is an existing directory.
return !$nok;
}
-=item cp
-
- cp source_file destination_file
- cp source_file source_file destination_dir
+=item cp source... destination
-Copies sources to the destination. Multiple sources are allowed if
+Copies source to destination. Multiple sources are allowed if
destination is an existing directory.
Returns true if all copies succeeded, false otherwise.
return $nok;
}
-=item chmod
-
- chmod mode files ...
+=item chmod mode files...
Sets UNIX like permissions 'mode' on all the files. e.g. 0666
chmod(oct $mode,@ARGV) || die "Cannot chmod ".join(' ',$mode,@ARGV).":$!";
}
-=item mkpath
-
- mkpath directory ...
+=item mkpath directory...
-Creates directories, including any parent directories.
+Creates directory, including any parent directories.
=cut
File::Path::mkpath([@ARGV],0,0777);
}
-=item test_f
-
- test_f file
+=item test_f file
Tests if a file exists
exit !-f $ARGV[0];
}
-=item dos2unix
+=item test_d directory
+
+Tests if a directory exists
+
+=cut
- dos2unix files or dirs ...
+sub test_d
+{
+ exit !-d $ARGV[0];
+}
+
+=item dos2unix
Converts DOS and OS/2 linefeeds to Unix style recursively.
=back
-=head1 SEE ALSO
+=head1 BUGS
-Shell::Command which is these same functions but take arguments normally.
+Should probably be Auto/Self loaded.
+
+=head1 SEE ALSO
+ExtUtils::MakeMaker, ExtUtils::MM_Unix, ExtUtils::MM_Win32
=head1 AUTHOR
Nick Ing-Simmons C<ni-s@cpan.org>
-Currently maintained by Michael G Schwern C<schwern@pobox.com>.
+Maintained by Michael G Schwern C<schwern@pobox.com> within the
+ExtUtils-MakeMaker package and, as a separate CPAN package, by
+Randy Kobes C<r.kobes@uwinnipeg.ca>.
=cut
}
BEGIN {
- use Test::More tests => 38;
+ use Test::More tests => 41;
use File::Spec;
}
BEGIN {
# bad neighbor, but test_f() uses exit()
- *CORE::GLOBAL::exit = ''; # quiet 'only once' warning.
- *CORE::GLOBAL::exit = sub { return $_[0] };
+ *CORE::GLOBAL::exit = ''; # quiet 'only once' warning.
+ *CORE::GLOBAL::exit = sub { return @_ };
use_ok( 'ExtUtils::Command' );
}
is( scalar( $$out =~ s/use_ok\( 'ExtUtils::Command'//g), 2,
'concatenation worked' );
- # the truth value here is reversed -- Perl true is shell false
+ # the truth value here is reversed -- Perl true is C false
@ARGV = ( $Testfile );
ok( test_f(), 'testing non-existent file' );
+ @ARGV = ( $Testfile );
+ cmp_ok( ! test_f(), '==', (-f $Testfile), 'testing non-existent file' );
+
# these are destructive, have to keep setting @ARGV
@ARGV = ( $Testfile );
touch();
@ARGV = ( $Testfile );
- ok( !test_f(), 'now creating that file' );
+ ok( test_f(), 'now creating that file' );
is_deeply( \@ARGV, [$Testfile], 'test_f preserves @ARGV' );
@ARGV = ( $Testfile );
$^O eq 'NetWare' || $^O eq 'dos' || $^O eq 'cygwin' ||
$^O eq 'MacOS'
) {
- skip( "different file permission semantics on $^O", 4);
+ skip( "different file permission semantics on $^O", 3);
}
# change a file to execute-only
is( ((stat('testdir'))[2] & 07777) & 0700,
0100, 'change a dir to execute-only' );
- # change a dir to write-only
- @ARGV = ( '0200', 'testdir' );
+ # change a dir to read-only
+ @ARGV = ( '0400', 'testdir' );
ExtUtils::Command::chmod();
is( ((stat('testdir'))[2] & 07777) & 0700,
- ($^O eq 'vos' ? 0700 : 0200), 'change a dir to write-only' );
+ ($^O eq 'vos' ? 0500 : 0400), 'change a dir to read-only' );
- # change a dir to read-only
- @ARGV = ( '0400', 'testdir' );
+ # change a dir to write-only
+ @ARGV = ( '0200', 'testdir' );
ExtUtils::Command::chmod();
is( ((stat('testdir'))[2] & 07777) & 0700,
- ($^O eq 'vos' ? 0500 : 0400), 'change a dir to read-only' );
+ ($^O eq 'vos' ? 0700 : 0200), 'change a dir to write-only' );
@ARGV = ('testdir');
rm_rf;
- ok( ! -e 'testdir', 'rm_rf can delete a read-only dir' );
}
# mkpath
- @ARGV = ( File::Spec->join( 'ecmddir', 'temp2' ) );
+ my $test_dir = File::Spec->join( 'ecmddir', 'temp2' );
+ @ARGV = ( $test_dir );
ok( ! -e $ARGV[0], 'temp directory not there yet' );
+ ok( test_d(), 'testing non-existent directory' );
+
+ @ARGV = ( $test_dir );
+ cmp_ok( ! test_d(), '==', (-d $test_dir), 'testing non-existent dir' );
+ @ARGV = ( $test_dir );
mkpath();
ok( -e $ARGV[0], 'temp directory created' );
+ cmp_ok( test_d(), '==', (-d $test_dir), 'testing existing dir' );
+ @ARGV = ( $test_dir );
# copy a file to a nested subdirectory
unshift @ARGV, $Testfile;
@orig_argv = @ARGV;