diff --git a/mvwrap/mvwrap b/mvwrap/mvwrap index 151c6ea..dbd5d68 100755 --- a/mvwrap/mvwrap +++ b/mvwrap/mvwrap @@ -22,14 +22,21 @@ unless (defined @source) { @source = &read_cur_dir; } if (@pattern) { @target = @source; &pattern_edit; + if ( &run_checks ) { + &cdie("Aborting\n"); + } } else { $temp_file = &open_temp; &edit($temp_file); &read_temp($temp_file); -} - -if ( &run_checks ) { - &cdie("Aborting\n"); + while ( &run_checks ) { + if ( &askyn("Do you want to continue editing") ) { + &edit($temp_file); + &read_temp($temp_file); + } else { + &cdie("Aborting\n"); + } + } } # if it's unsafe to move files directly, move the unsafe ones to a @@ -86,6 +93,7 @@ sub open_temp { sub read_temp($) { my $target_name = shift; open TARGET, $target_name or &cdie("Couldn't open tempfile: $target_name: $!"); + @target = (); foreach () { chomp; push @target, $_; @@ -299,6 +307,20 @@ sub cdie { die "$message"; } +sub askyn($) { + my $question = shift; + while (1) { + print "$question [y/n]? "; + $line = <>; + if ( $line =~ /^y$/ ) { + return 1; + } elsif ( $line =~ /^n$/ ) { + return 0; + } + } +} + + # parse commandline sub cmdline { %optctl = ();