From: Jarkko Hietaniemi Date: Sun, 24 Jun 2001 02:12:04 +0000 (+0000) Subject: Allow (displaying and) re-editing the Subject in perlbug. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2e7f46bf89c43d7db1b6f05280f4be821d5e2b32;p=p5sagit%2Fp5-mst-13.2.git Allow (displaying and) re-editing the Subject in perlbug. Also abstract the Subject quality control into a function. p4raw-id: //depot/perl@10878 --- diff --git a/utils/perlbug.PL b/utils/perlbug.PL index 201b3f5..de848ae 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 <; 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 <; - 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 <; - chop $action; + chomp $action; if ($action =~ /^(f|sa)/i) { # ile/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 () { print $_ } close(REP) or die "Error closing report file `$filename': $!"; + } elsif ($action =~ /^su/i) { # 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 ; + chomp $reply; + if ($reply ne '') { + unless (TrivialSubject($reply)) { + $subject = $reply; + print "Subject: $subject\n"; + } + } } elsif ($action =~ /^se/i) { # end # Send the message print "Are you certain you want to send this message?\n" . 'Please type "yes" if you are: '; my $reply = scalar ; - 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) {