diff --git a/mvwrap/mvwrap b/mvwrap/mvwrap index d1706ad..f7e631a 100755 --- a/mvwrap/mvwrap +++ b/mvwrap/mvwrap @@ -103,9 +103,10 @@ sub move_files { chomp($source); chomp($target); unless ( $source eq $target ) { - if ($opt_v) { + if ($opt_v||$opt_t) { print "mv $source $target\n"; - } else { + } + unless ($opt_t) { move("$source", "$target") or die "move failed: $!"; } @@ -198,9 +199,10 @@ sub safety_belt { $filename = $source->[$filenr]; chomp $filename; $rand = &rand_file; - if ($opt_v) { + if ($opt_v||$opt_t) { print "mv $filename $rand\n"; - } else { + } + unless ($opt_t) { move("$filename", "$rand") or die "move failed: $!"; } @@ -241,7 +243,7 @@ sub unlock { sub cmdline { %optctl = (); - &GetOptions("e=s", "h", "p=s", \@pattern, "f=s", "v"); + &GetOptions("e=s", "h", "p=s", \@pattern, "f=s", "v", "t"); &GetOptions(\%optctl, "e"); &help if $opt_h; @@ -270,7 +272,8 @@ 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 +-v verbose; shows file moves +-t test; doesn't move, implies -v Specifying fiels on the command line is still unsafe! There are no checks to prevent overwriting non-specified files!