make it possible to continue editing in interactive mode to correct errors
This commit is contained in:
parent
fdc7371f0e
commit
462de5d6e1
1 changed files with 26 additions and 4 deletions
|
|
@ -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 (<TARGET>) {
|
||||
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 = ();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue