This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlbug: Ask confirmation if would overwrite existing file
authorKarl Williamson <khw@cpan.org>
Tue, 3 Apr 2018 16:27:25 +0000 (10:27 -0600)
committerKarl Williamson <khw@cpan.org>
Sun, 15 Apr 2018 22:48:46 +0000 (16:48 -0600)
This adds a prompt asking for confirmation if the perlbug report would
overwrite an existing file. My guess is that the normal answer will be
yes.

utils/perlbug.PL

index 3273902..d1eb1e0 100644 (file)
@@ -1122,6 +1122,10 @@ sub build_complete_message {
 sub save_message_to_disk {
     my $file = shift;
 
 sub save_message_to_disk {
     my $file = shift;
 
+        if (-e $file) {
+            my $response = _prompt( '', "Overwrite existing '$file'", 'n' );
+            return undef unless $response =~ / yes | y /xi;
+        }
         open OUTFILE, '>:raw', $file or do { warn  "Couldn't open '$file': $!\n"; return undef};
         binmode(OUTFILE, ':raw :crlf') if $Is_MSWin32;
 
         open OUTFILE, '>:raw', $file or do { warn  "Couldn't open '$file': $!\n"; return undef};
         binmode(OUTFILE, ':raw :crlf') if $Is_MSWin32;