From 9281bc5381cfb7a11cc6470de4a4766c4ff8f771 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Wed, 6 Nov 2002 21:15:18 +0000 Subject: (cp): use cp_af --- perl-install/commands.pm | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/perl-install/commands.pm b/perl-install/commands.pm index f3503eb10..3808d6848 100644 --- a/perl-install/commands.pm +++ b/perl-install/commands.pm @@ -222,42 +222,8 @@ sub ls { } } sub cp { - my ($force) = getopts(\@_, qw(f)); - @_ >= 2 or die "usage: cp [-f] \n(this cp does -Rl by default)\n"; - - my $cp; $cp = sub { - my $dest = pop @_; - - @_ or return; - @_ == 1 || -d $dest or die "cp: copying multiple files, but last argument ($dest) is not a directory\n"; - - foreach my $src (@_) { - my $dest = $dest; - -d $dest and $dest .= "/" . basename($src); - - if (-e $dest) { - $force ? unlink $dest : die "file $dest already exist\n"; - } - - if (-d $src) { - -d $dest or mkdir $dest, (stat($src))[2] or die "mkdir: can't create directory $dest: $!\n"; - &$cp(glob_($src), $dest); - } elsif (-l $src) { - unless (symlink((readlink($src) || die "readlink failed: $!"), $dest)) { - my $msg = "symlink: can't create symlink $dest: $!\n"; - $force ? warn $msg : die $msg; - } - } else { - local (*F, *G); - open F, $src or die "can't open $src for reading: $!\n"; - open G, "> $dest" or $force or die "can't create $dest : $!\n"; - local $_; - while () { print G $_ } - chmod((stat($src))[2], $dest); - } - } - }; - &$cp(@_); + @_ >= 2 or die "usage: cp \n(this cp does -Rfl by default)\n"; + cp_af(@_); } sub ps { -- cgit v1.2.1