diff --git a/mvwrap/mvwrap b/mvwrap/mvwrap index f0c2b1f..d1706ad 100755 --- a/mvwrap/mvwrap +++ b/mvwrap/mvwrap @@ -100,11 +100,15 @@ sub move_files { for ( $i=0; $i < scalar(@$from); $i++ ) { $source=$from->[$i]; $target=$to->[$i]; + chomp($source); + chomp($target); unless ( $source eq $target ) { - chomp($source); - chomp($target); - move("$source", "$target") - or die "move failed: $!"; + if ($opt_v) { + print "mv $source $target\n"; + } else { + move("$source", "$target") + or die "move failed: $!"; + } } } } @@ -139,7 +143,7 @@ sub run_checks { foreach $line (@target) { if ( $line =~ m/^$/ ) { 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]; chomp $filename; $rand = &rand_file; - move("$filename", "$rand") + if ($opt_v) { + print "mv $filename $rand\n"; + } else { + move("$filename", "$rand") or die "move failed: $!"; + } $source->[$filenr] = "$rand\n"; } } @@ -233,7 +241,7 @@ sub unlock { sub cmdline { %optctl = (); - &GetOptions("e=s", "h", "p=s", \@pattern, "f=s"); + &GetOptions("e=s", "h", "p=s", \@pattern, "f=s", "v"); &GetOptions(\%optctl, "e"); &help if $opt_h; @@ -262,6 +270,7 @@ At the moment it takes the following options: -e invoke with this editor; ignored if -f or -p is given -p use a pattern to edit; ignored if -f is given -f 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 to prevent overwriting non-specified files!