-v optie ge\"implementeerd, voor verbose/verify kun je eerst

je moves checken. Waarschijnlijk handig samen met -p
This commit is contained in:
Ward Wouts 2002-01-19 21:45:04 +00:00
parent 5bcdc11ee3
commit 52c46b71a4

View file

@ -100,11 +100,15 @@ sub move_files {
for ( $i=0; $i < scalar(@$from); $i++ ) { for ( $i=0; $i < scalar(@$from); $i++ ) {
$source=$from->[$i]; $source=$from->[$i];
$target=$to->[$i]; $target=$to->[$i];
chomp($source);
chomp($target);
unless ( $source eq $target ) { unless ( $source eq $target ) {
chomp($source); if ($opt_v) {
chomp($target); print "mv $source $target\n";
move("$source", "$target") } else {
or die "move failed: $!"; move("$source", "$target")
or die "move failed: $!";
}
} }
} }
} }
@ -139,7 +143,7 @@ sub run_checks {
foreach $line (@target) { foreach $line (@target) {
if ( $line =~ m/^$/ ) { if ( $line =~ m/^$/ ) {
if ( -e ".mv_wrap" ) { unlink (".mv_wrap"); } if ( -e ".mv_wrap" ) { unlink (".mv_wrap"); }
die "Aborting. You can't move to empy names.\n"; die "Aborting. You can't move to empty names.\n";
} }
} }
@ -194,8 +198,12 @@ sub safety_belt {
$filename = $source->[$filenr]; $filename = $source->[$filenr];
chomp $filename; chomp $filename;
$rand = &rand_file; $rand = &rand_file;
move("$filename", "$rand") if ($opt_v) {
print "mv $filename $rand\n";
} else {
move("$filename", "$rand")
or die "move failed: $!"; or die "move failed: $!";
}
$source->[$filenr] = "$rand\n"; $source->[$filenr] = "$rand\n";
} }
} }
@ -233,7 +241,7 @@ sub unlock {
sub cmdline { sub cmdline {
%optctl = (); %optctl = ();
&GetOptions("e=s", "h", "p=s", \@pattern, "f=s"); &GetOptions("e=s", "h", "p=s", \@pattern, "f=s", "v");
&GetOptions(\%optctl, "e"); &GetOptions(\%optctl, "e");
&help if $opt_h; &help if $opt_h;
@ -262,6 +270,7 @@ At the moment it takes the following options:
-e <editor> invoke with this editor; ignored if -f or -p is given -e <editor> invoke with this editor; ignored if -f or -p is given
-p <pattern> use a pattern to edit; ignored if -f is given -p <pattern> use a pattern to edit; ignored if -f is given
-f <file> use a pattern file to edit -f <file> use a pattern file to edit
-v verify/verbose; shows file moves that would happen without -v
Specifying fiels on the command line is still unsafe! There are no checks Specifying fiels on the command line is still unsafe! There are no checks
to prevent overwriting non-specified files! to prevent overwriting non-specified files!