-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,14 +100,18 @@ 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];
unless ( $source eq $target ) {
chomp($source); chomp($source);
chomp($target); chomp($target);
unless ( $source eq $target ) {
if ($opt_v) {
print "mv $source $target\n";
} else {
move("$source", "$target") move("$source", "$target")
or die "move failed: $!"; or die "move failed: $!";
} }
} }
} }
}
# read pattern file # read pattern file
sub read_pattern { sub read_pattern {
@ -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;
if ($opt_v) {
print "mv $filename $rand\n";
} else {
move("$filename", "$rand") 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!