4 use File::Basename qw(&basename &dirname);
6 # List explicitly here the variables you want Configure to
7 # generate. Metaconfig only looks for shell variables, so you
8 # have to mention them as if they were shell variables, not
9 # %Config entries. Thus you write
11 # to ensure Configure will look for $Config{startperl}.
13 # This forces PL files to create target in same directory as PL file.
14 # This is so that make depend always knows where to find PL derivatives.
16 ($file = basename($0)) =~ s/\.PL$//;
18 if ($Config{'osname'} eq 'VMS' or
19 $Config{'osname'} eq 'OS2'); # "case-forgiving"
21 open OUT,">$file" or die "Can't create $file: $!";
23 print "Extracting $file (with variable substitutions)\n";
25 # In this section, perl variables will be expanded during extraction.
26 # You can use $Config{...} to use Configure variables.
28 print OUT <<"!GROK!THIS!";
30 eval 'exec perl -S \$0 "\$@"'
34 # In the following, perl variables are not expanded during extraction.
36 print OUT <<'!NO!SUBS!';
42 eval "use Mail::Send;";
43 $::HaveSend = ($@ eq "");
44 eval "use Mail::Util;";
45 $::HaveUtil = ($@ eq "");
54 my($Version) = "1.11";
56 # Changed in 1.06 to skip Mail::Send and Mail::Util if not available.
57 # Changed in 1.07 to see more sendmail execs, and added pipe output
58 # Changed in 1.08 to use correct address for sendmail
59 # Changed in 1.09 to close the REP file before calling it up in the editor.
60 # Also removed some old comments duplicated elsewhere.
61 # Changed in 1.10 to run under VMS without Mail::Send; also fixed
62 # temp filename generation
63 # Changed in 1.11 to clean up some text and removed Mail::Send deactivator.
65 # TODO: Allow the user to re-name the file on mail failure, and
66 # make sure failure (transmission-wise) of Mail::Send is
69 my( $file, $cc, $address, $perlbug, $testaddress, $filename,
70 $subject, $from, $verbose, $ed,
71 $fh, $me, $Is_VMS, $msg, $body, $andcc );
75 if($::opt_h) { Help(); exit; }
77 if($::opt_d or !-t STDOUT) { Dump(*STDOUT); exit; }
88 # -------- Setup --------
90 $Is_VMS = $::Config{'osname'} eq 'VMS';
92 getopts("dhva:s:b:f:r:e:SCc:t");
95 # This comment is needed to notify metaconfig that we are
96 # using the $perladmin, $cf_by, and $cf_time definitions.
99 # -------- Configuration ---------
102 $perlbug = 'perlbug@perl.com';
105 $testaddress = 'perlbug-test@perl.com';
108 $address = $::opt_a || ($::opt_t ? $testaddress : $perlbug);
110 # Possible administrator addresses, in order of confidence
111 # (Note that cf_email is not mentioned to metaconfig, since
112 # we don't really want it. We'll just take it if we have to.)
113 $cc = ($::opt_C ? "" : (
114 $::opt_c || $::Config{perladmin} || $::Config{cf_email} || $::Config{cf_by}
117 # Users address, used in message and in Reply-To header
118 $from = $::opt_r || "";
120 # Include verbose configuration information
121 $verbose = $::opt_v || 0;
123 # Subject of bug-report message
124 $subject = $::opt_s || "";
126 # File to send as report
127 $file = $::opt_f || "";
130 $body = $::opt_b || "";
133 $ed = ($::opt_f ? "file" : (
134 $::opt_e || $ENV{VISUAL} || $ENV{EDITOR} || $ENV{EDIT} ||
135 ($Is_VMS ? "edit/tpu" : "vi")
146 # Explain what perlbug is
149 This program allows you to create a bug report,
150 which will be sent as an e-mail message to $address
151 once you have filled in the report.
156 # Prompt for subject of message, if needed
159 First of all, please provide a subject for the
160 message. It should be as a concise description of
161 the bug as is possible.
170 while( $subject =~ /^\s*$/ ) {
171 print "\nPlease enter a subject: ";
181 # Prompt for return address, if needed
184 # Try and guess return address
188 $domain = Mail::Util::maildomain();
190 require Sys::Hostname;
191 $domain = Sys::Hostname::hostname();
193 $domain = `hostname`.".".`domainname`;
194 $domain =~ s/[\r\n]+//g;
201 } elsif ($Is_VMS && !$::Config{'d_has_sockets'}) {
202 $guess = "$domain\:\:$me";
204 $guess = "$me\@$domain" if $domain;
205 $guess = "$me\@unknown.addresss" unless $domain;
212 Your e-mail address will be useful if you need to be contacted.
213 If the default shown is not your proper address, please correct it.
219 So that you may be contacted if necessary, please enter
220 your e-mail address here.
224 print "Your address [$guess]: ";
229 if($from eq "") { $from = $guess }
233 #if( $from =~ /^(.*)\@(.*)$/ ) {
238 if( $from eq $cc or $me eq $cc ) {
239 # Try not to copy ourselves
244 # Prompt for administrator address, unless an override was given
245 if( !$::opt_C and !$::opt_c ) {
249 A copy of this report can be sent to your local
250 perl administrator. If the address is wrong, please
251 correct it, or enter 'none' or 'yourself' to not send
256 print "Local perl administrator [$cc]: ";
258 my($entry) = scalar(<>);
263 if($me eq $cc) { $cc = "" }
268 if($cc =~ /^(none|yourself|myself|ourselves)$/i) { $cc = "" }
270 $andcc = " and $cc" if $cc;
273 # Prompt for editor, if no override is given
274 if(! $::opt_e and ! $::opt_f and ! $::opt_b) {
278 Now you need to supply the bug report. Try to make
279 the report concise but descriptive. Include any
280 relevant detail. Some information about your local
281 perl configuration will automatically be included
282 at the end of the report.
284 You will probably want to use an editor to enter
285 the report. If "$ed" is the editor you want
286 to use, then just press Enter, otherwise type in
287 the name of the editor you would like to use.
289 If you would like to use a prepared file, type
290 "file", and you will be asked for the filename.
294 print "Editor [$ed]: ";
296 my($entry) =scalar(<>);
305 # Generate scratch file to edit report in
308 my($dir) = $Is_VMS ? 'sys$scratch:' : '/tmp/';
309 $filename = "bugrep0$$";
310 $filename++ while -e "$dir$filename";
311 $filename = "$dir$filename";
315 # Prompt for file to read report from, if needed
317 if( $ed eq "file" and ! $file) {
321 What is the name of the file that contains your report?
327 my($entry) = scalar(<>);
330 if(!-f $entry or !-r $entry) {
331 print "\n\nUnable to read from `$entry'.\nExiting.\n";
341 open(REP,">$filename");
344 This is a bug report for perl from $from,
345 generated with the help of perlbug $Version running under perl $].
352 open(F,"<$file") or die "Unable to read report file: $!\n";
358 print REP "[Please enter your report here]\n";
373 Site configuration information for perl $]:
377 if( $::Config{cf_by} and $::Config{cf_time}) {
378 print OUT "Configured by $::Config{cf_by} at $::Config{cf_time}.\n\n";
381 print OUT Config::myconfig;
384 print OUT "\nComplete configuration data for perl $]:\n\n";
386 foreach (sort keys %::Config) {
387 $value = $::Config{$_};
389 print OUT "$_='$value'\n";
397 if(!$file and !$body) {
398 my($sts) = system("$ed $filename");
399 if( $Is_VMS ? !($sts & 1) : $sts ) {
400 print "\nUnable to run editor!\n";
407 # Report is done, prompt for further action
414 Now that you have completed your report, would you like to send
415 the message to $address$andcc, display the message on
416 the screen, re-edit it, or cancel without sending anything?
417 You may also save the message as a file to mail at another time.
421 print "Action (Send/Display/Edit/Cancel/File): ";
422 my($action) = scalar(<>);
425 if($action =~ /^s/i) { # Send
428 } elsif($action =~ /^f/i) { # File
429 print "\n\nName of file to save message in [perlbug.rep]: ";
430 my($file) = scalar(<>);
432 if($file eq "") { $file = "perlbug.rep" }
435 open(REP,"<$filename");
436 print FILE "To: $address\nSubject: $subject\n";
437 print FILE "Cc: $cc\n" if $cc;
438 print FILE "Reply-To: $from\n" if $from;
440 while(<REP>) { print FILE }
444 print "\nMessage saved in `$file'.\n";
447 } elsif($action =~ /^[drl]/i) { # Display, Redisplay, List
448 # Display the message
449 open(REP,"<$filename");
450 while(<REP>) { print $_ }
452 } elsif($action =~ /^e/i) { # Edit
454 system("$ed $filename");
455 } elsif($action =~ /^[qc]/i) { # Cancel, Quit
456 1 while unlink($filename); # remove all versions under VMS
457 print "\nCancelling.\n";
468 # Message has been accepted for transmission -- Send the message
472 $msg = new Mail::Send Subject => $subject, To => $address;
474 $msg->cc($cc) if $cc;
475 $msg->add("Reply-To",$from) if $from;
479 open(REP,"<$filename");
480 while(<REP>) { print $fh $_ }
487 if ( ($address =~ /@/ and $address !~ /^\w+%"/) or
488 ($cc =~ /@/ and $cc !~ /^\w+%"/) ){
490 foreach (qw[ IN MX SMTP UCX PONY WINS ],'') {
491 $prefix = "$_%",last if $ENV{"MAIL\$PROTOCOL_$_"};
493 $address = qq[${prefix}"$address"] unless $address =~ /^\w+%"/;
494 $cc = qq[${prefix}"$cc"] unless !$cc || $cc =~ /^\w+%"/;
496 $subject =~ s/"/""/g; $address =~ s/"/""/g; $cc =~ s/"/""/g;
497 my($sts) = system(qq[mail/Subject="$subject" $filename. "$address","$cc"]);
498 if (!($sts & 1)) { die "Can't spawn off mail\n\t(leaving bug report in $filename): $sts\n;" }
502 foreach (qw(/usr/lib/sendmail /usr/sbin/sendmail /usr/ucblib/sendmail))
504 $sendmail = $_, last if -e $_;
507 paraprint <<"EOF" and die "\n" if $sendmail eq "";
509 I am terribly sorry, but I cannot find sendmail, or a close equivalent, and
510 the perl package Mail::Send has not been installed, so I can't send your bug
511 report. We apologize for the inconveniencence.
513 So you may attempt to find some way of sending your message, it has
514 been left in the file `$filename'.
518 open(SENDMAIL,"|$sendmail -t");
519 print SENDMAIL "To: $address\n";
520 print SENDMAIL "Subject: $subject\n";
521 print SENDMAIL "Cc: $cc\n" if $cc;
522 print SENDMAIL "Reply-To: $from\n" if $from;
523 print SENDMAIL "\n\n";
524 open(REP,"<$filename");
525 while(<REP>) { print SENDMAIL $_ }
533 print "\nMessage sent.\n";
535 1 while unlink($filename); # remove all versions under VMS
542 A program to help generate bug reports about perl5, and mail them.
543 It is designed to be used interactively. Normally no arguments will
547 $0 [-v] [-a address] [-s subject] [-b body | -f file ]
548 [-r returnaddress] [-e editor] [-c adminaddress | -C] [-S] [-t]
550 Simplest usage: run "$0", and follow the prompts.
554 -v Include Verbose configuration data in the report
555 -f File containing the body of the report. Use this to
556 quickly send a prepared message.
557 -S Send without asking for confirmation.
558 -a Address to send the report to. Defaults to `$address'.
559 -c Address to send copy of report to. Defaults to `$cc'.
560 -C Don't send copy to administrator.
561 -s Subject to include with the message. You will be prompted
562 if you don't supply one on the command line.
563 -b Body of the report. If not included on the command line, or
564 in a file with -f, you will get a chance to edit the message.
565 -r Your return address. The program will ask you to confirm
566 this if you don't give it here.
568 -t Test mode. The target address defaults to `$testaddress'.
569 -d Data mode (the default if you redirect or pipe output.)
570 This prints out your configuration data, without mailing
571 anything. You can use this with -v to get more complete data.
577 my @paragraphs = split /\n{2,}/, "@_";
579 for (@paragraphs) { # implicit local $_
589 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
594 close OUT or die "Can't close $file: $!";
595 chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
596 exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';