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) {
|
if (@pattern) {
|
||||||
@target = @source;
|
@target = @source;
|
||||||
&pattern_edit;
|
&pattern_edit;
|
||||||
|
if ( &run_checks ) {
|
||||||
|
&cdie("Aborting\n");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$temp_file = &open_temp;
|
$temp_file = &open_temp;
|
||||||
&edit($temp_file);
|
&edit($temp_file);
|
||||||
&read_temp($temp_file);
|
&read_temp($temp_file);
|
||||||
}
|
while ( &run_checks ) {
|
||||||
|
if ( &askyn("Do you want to continue editing") ) {
|
||||||
if ( &run_checks ) {
|
&edit($temp_file);
|
||||||
|
&read_temp($temp_file);
|
||||||
|
} else {
|
||||||
&cdie("Aborting\n");
|
&cdie("Aborting\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# if it's unsafe to move files directly, move the unsafe ones to a
|
# if it's unsafe to move files directly, move the unsafe ones to a
|
||||||
|
|
@ -86,6 +93,7 @@ sub open_temp {
|
||||||
sub read_temp($) {
|
sub read_temp($) {
|
||||||
my $target_name = shift;
|
my $target_name = shift;
|
||||||
open TARGET, $target_name or &cdie("Couldn't open tempfile: $target_name: $!");
|
open TARGET, $target_name or &cdie("Couldn't open tempfile: $target_name: $!");
|
||||||
|
@target = ();
|
||||||
foreach (<TARGET>) {
|
foreach (<TARGET>) {
|
||||||
chomp;
|
chomp;
|
||||||
push @target, $_;
|
push @target, $_;
|
||||||
|
|
@ -299,6 +307,20 @@ sub cdie {
|
||||||
die "$message";
|
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
|
# parse commandline
|
||||||
sub cmdline {
|
sub cmdline {
|
||||||
%optctl = ();
|
%optctl = ();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue