diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-06-24 02:12:04 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-06-24 02:12:04 +0000 |
commit | 2e7f46bf89c43d7db1b6f05280f4be821d5e2b32 (patch) | |
tree | cd7139c7fc3afc5d08513f1e0fda8a063dfeef62 /utils | |
parent | 27414c22f9f9e053d924f2fe0a81c39c62ec27e0 (diff) | |
download | perl-2e7f46bf89c43d7db1b6f05280f4be821d5e2b32.tar.gz |
Allow (displaying and) re-editing the Subject in perlbug.
Also abstract the Subject quality control into a function.
p4raw-id: //depot/perl@10878
Diffstat (limited to 'utils')
-rw-r--r-- | utils/perlbug.PL | 66 |
1 files changed, 48 insertions, 18 deletions
diff --git a/utils/perlbug.PL b/utils/perlbug.PL index 201b3f5d10..de848ae009 100644 --- a/utils/perlbug.PL +++ b/utils/perlbug.PL @@ -342,6 +342,11 @@ EOF } # Prompt for subject of message, if needed + + if (TrivialSubject($subject)) { + $subject = ''; + } + unless ($subject) { paraprint <<EOF; First of all, please provide a subject for the @@ -349,18 +354,16 @@ message. It should be a concise description of the bug or problem. "perl bug" or "perl problem" is not a concise description. EOF - print "Subject: "; - $subject = <>; my $err = 0; - while ($subject !~ /\S/) { - print "\nPlease enter a subject: "; + do { + print "Subject: "; $subject = <>; - if ($err++ > 5) { + chomp $subject; + if ($err++ == 5) { die "Aborting.\n"; } - } - chop $subject; + } while (TrivialSubject($subject)); } # Prompt for return address, if needed @@ -416,7 +419,7 @@ EOF # verify it print "Your address [$guess]: "; $from = <>; - chop $from; + chomp $from; $from = $guess if $from eq ''; } } @@ -436,7 +439,7 @@ a copy. EOF print "Local perl administrator [$cc]: "; my $entry = scalar <>; - chop $entry; + chomp $entry; if ($entry ne "") { $cc = $entry; @@ -474,7 +477,7 @@ If you would like to use a prepared file, type EOF print "Editor [$ed]: "; my $entry =scalar <>; - chop $entry; + chomp $entry; $usefile = 0; if ($entry eq "file") { @@ -501,7 +504,7 @@ What is the name of the file that contains your report? EOF print "Filename: "; my $entry = scalar <>; - chop $entry; + chomp $entry; if ($entry eq "") { paraprint <<EOF; @@ -645,7 +648,7 @@ Please make sure that the name of the editor you want to use is correct. EOF print "Editor [$ed]: "; my $entry =scalar <>; - chop $entry; + chomp $entry; $ed = $entry unless $entry eq ''; } @@ -668,7 +671,7 @@ correct it here, otherwise just press Enter. EOF print "Editor [$ed]: "; my $entry =scalar <>; - chop $entry; + chomp $entry; if ($entry ne "") { $ed = $entry; @@ -722,19 +725,20 @@ sub NowWhat { paraprint <<EOF; Now that you have completed your report, would you like to send the message to $address$andcc, display the message on -the screen, re-edit it, or cancel without sending anything? +the screen, re-edit it, display/change the subject, +or cancel without sending anything? You may also save the message as a file to mail at another time. EOF retry: - print "Action (Send/Display/Edit/Cancel/Save to File): "; + print "Action (Send/Display/Edit/Subject/Save to File): "; my $action = scalar <>; - chop $action; + chomp $action; if ($action =~ /^(f|sa)/i) { # <F>ile/<Sa>ve my $file_save = $outfile || "perlbug.rep"; print "\n\nName of file to save message in [$file_save]: "; my $file = scalar <>; - chop $file; + chomp $file; $file = $file_save if $file eq ""; unless (open(FILE, ">$file")) { @@ -757,12 +761,25 @@ EOF open(REP, "<$filename") or die "Couldn't open file `$filename': $!\n"; while (<REP>) { print $_ } close(REP) or die "Error closing report file `$filename': $!"; + } elsif ($action =~ /^su/i) { # <Su>bject + print "Subject: $subject\n"; + print "If the above subject is fine, just press Enter.\n"; + print "If not, type in the new subject.\n"; + print "Subject: "; + my $reply = scalar <STDIN>; + chomp $reply; + if ($reply ne '') { + unless (TrivialSubject($reply)) { + $subject = $reply; + print "Subject: $subject\n"; + } + } } elsif ($action =~ /^se/i) { # <S>end # Send the message print "Are you certain you want to send this message?\n" . 'Please type "yes" if you are: '; my $reply = scalar <STDIN>; - chop $reply; + chomp $reply; if ($reply eq "yes") { last; } else { @@ -786,6 +803,19 @@ EOF } } # sub NowWhat +sub TrivialSubject { + my $subject = shift; + if ($subject =~ + /^(y(es)?|no?|help|perl( (bug|problem))?|bug|problem)$/i || + length($subject) < 4 || + $subject !~ /\s/) { + print "\nThat doesn't look like a good subject. Please be more verbose.\n\n"; + return 1; + } else { + return 0; + } +} + sub Send { # Message has been accepted for transmission -- Send the message if ($outfile) { |