Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perlbug overwrite existing perlbug.rep without notice #16386

Closed
p5pRT opened this issue Jan 27, 2018 · 8 comments
Closed

perlbug overwrite existing perlbug.rep without notice #16386

p5pRT opened this issue Jan 27, 2018 · 8 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 27, 2018

Migrated from rt.perl.org#132773 (status was 'resolved')

Searchable as RT132773$

@p5pRT
Copy link
Author

p5pRT commented Jan 27, 2018

From konkove@gmail.com

Hi.

When new report is created the `perlbug` suggest file name​:

  Name of file to save message in [perlbug.rep]​:

But in case this file already exists it is overwrited without notice.

  Name of file to save message in [perlbug.rep]​:

  Message saved.

There should be some warning about that or it should suggest
unexisting file name.
For example​: perlbug2.rep

@p5pRT
Copy link
Author

p5pRT commented Apr 3, 2018

From @khwilliamson

On Sat, 27 Jan 2018 02​:33​:37 -0800, konkove@​gmail.com wrote​:

Hi.

When new report is created the `perlbug` suggest file name​:

Name of file to save message in \[perlbug\.rep\]​:

But in case this file already exists it is overwrited without notice.

Name of file to save message in \[perlbug\.rep\]​:

Message saved\.

There should be some warning about that or it should suggest
unexisting file name.
For example​: perlbug2.rep

How about the attached patch?
--
Karl Williamson

@p5pRT
Copy link
Author

p5pRT commented Apr 3, 2018

From @khwilliamson

0006-perlbug-Ask-confirmation-if-would-overwrite-existing.patch
From 4374d262902bd8dfbaaee642169cc73560edf354 Mon Sep 17 00:00:00 2001
From: Karl Williamson <khw@cpan.org>
Date: Tue, 3 Apr 2018 10:27:25 -0600
Subject: [PATCH 6/6] perlbug: Ask confirmation if would overwrite existing
 file

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 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/utils/perlbug.PL b/utils/perlbug.PL
index 3273902d0b..d1eb1e04a8 100644
--- a/utils/perlbug.PL
+++ b/utils/perlbug.PL
@@ -1122,6 +1122,10 @@ sub build_complete_message {
 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;
 
-- 
2.11.0

@p5pRT
Copy link
Author

p5pRT commented Apr 3, 2018

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Apr 17, 2018

From @khwilliamson

Since I didn't get feedback, and the deadline for 5.28 is upon us, I pushed that patch as commit fbb64cf
--
Karl Williamson

@p5pRT
Copy link
Author

p5pRT commented Apr 17, 2018

@khwilliamson - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2018

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release yesterday of Perl 5.28.0, this and 185 other issues have been
resolved.

Perl 5.28.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.28.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2018

@khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant