xref: /openbsd/gnu/usr.bin/perl/utils/perlbug.PL (revision 09467b48)
1#!/usr/local/bin/perl
2
3use Config;
4use File::Basename qw(&basename &dirname);
5use Cwd;
6use File::Spec::Functions;
7
8# List explicitly here the variables you want Configure to
9# generate.  Metaconfig only looks for shell variables, so you
10# have to mention them as if they were shell variables, not
11# %Config entries.  Thus you write
12#  $startperl
13# to ensure Configure will look for $Config{startperl}.
14#  $perlpath
15
16# This forces PL files to create target in same directory as PL file.
17# This is so that make depend always knows where to find PL derivatives.
18$origdir = cwd;
19chdir dirname($0);
20$file = basename($0, '.PL');
21$file .= '.com' if $^O eq 'VMS';
22
23open OUT, ">", $file or die "Can't create $file: $!";
24
25# get patchlevel.h timestamp
26
27-e catfile(updir, "patchlevel.h")
28    or die "Can't find patchlevel.h: $!";
29
30my $patchlevel_date = (stat _)[9];
31
32# TO DO (perhaps): store/embed $Config::config_sh into perlbug. When perlbug is
33# used, compare $Config::config_sh with the stored version. If they differ then
34# append a list of individual differences to the bug report.
35
36
37print "Extracting $file (with variable substitutions)\n";
38
39# In this section, perl variables will be expanded during extraction.
40# You can use $Config{...} to use Configure variables.
41
42my $extract_version = sprintf("%vd", $^V);
43
44print OUT <<"!GROK!THIS!";
45$Config{startperl}
46    eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
47	if \$running_under_some_shell;
48
49my \$config_tag1 = '$extract_version - $Config{cf_time}';
50
51my \$patchlevel_date = $patchlevel_date;
52!GROK!THIS!
53
54# In the following, perl variables are not expanded during extraction.
55
56print OUT <<'!NO!SUBS!';
57my @patches = Config::local_patches();
58my $patch_tags = join "", map /(\S+)/ ? "+$1 " : (), @patches;
59
60BEGIN { pop @INC if $INC[-1] eq '.' }
61use warnings;
62use strict;
63use Config;
64use File::Spec;		# keep perlbug Perl 5.005 compatible
65use Getopt::Std;
66use File::Basename 'basename';
67
68$Getopt::Std::STANDARD_HELP_VERSION = 1;
69
70sub paraprint;
71
72BEGIN {
73    eval { require Mail::Send;};
74    $::HaveSend = ($@ eq "");
75    eval { require Mail::Util; } ;
76    $::HaveUtil = ($@ eq "");
77    # use secure tempfiles wherever possible
78    eval { require File::Temp; };
79    $::HaveTemp = ($@ eq "");
80    eval { require Module::CoreList; };
81    $::HaveCoreList = ($@ eq "");
82    eval { require Text::Wrap; };
83    $::HaveWrap = ($@ eq "");
84};
85
86our $VERSION = "1.41";
87
88#TODO:
89#       make sure failure (transmission-wise) of Mail::Send is accounted for.
90#       (This may work now. Unsure of the original author's issue -JESSE 2008-06-08)
91#       - Test -b option
92
93my( $file, $usefile, $cc, $address, $bugaddress, $testaddress, $thanksaddress,
94    $filename, $messageid, $domain, $subject, $from, $verbose, $ed, $outfile,
95    $fh, $me, $body, $andcc, %REP, $ok, $thanks, $progname,
96    $Is_MSWin32, $Is_Linux, $Is_VMS, $Is_OpenBSD,
97    $report_about_module, $category, $severity,
98    %opt, $have_attachment, $attachments, $has_patch, $mime_boundary
99);
100
101my $running_noninteractively = !-t STDIN;
102
103my $perl_version = $^V ? sprintf("%vd", $^V) : $];
104
105my $config_tag2 = "$perl_version - $Config{cf_time}";
106
107Init();
108
109if ($opt{h}) { Help(); exit; }
110if ($opt{d}) { Dump(*STDOUT); exit; }
111if ($running_noninteractively && !$opt{t} && !($ok and not $opt{n})) {
112    paraprint <<"EOF";
113Please use $progname interactively. If you want to
114include a file, you can use the -f switch.
115EOF
116    die "\n";
117}
118
119Query();
120Edit() unless $usefile || ($ok and not $opt{n});
121NowWhat();
122if ($outfile) {
123    save_message_to_disk($outfile);
124} else {
125    Send();
126    if ($thanks) {
127	print "\nThank you for taking the time to send a thank-you message!\n\n";
128
129	paraprint <<EOF
130Please note that mailing lists are moderated, your message may take a while to
131show up.
132EOF
133    } else {
134	print "\nThank you for taking the time to file a bug report!\n\n";
135
136	paraprint <<EOF
137Please note that mailing lists are moderated, your message may take a while to
138show up. If you do not receive an automated response acknowledging your message
139within a few hours (check your SPAM folder and outgoing mail) please consider
140sending an email directly from your mail client to perlbug\@perl.org.
141EOF
142    }
143
144}
145
146exit;
147
148sub ask_for_alternatives { # (category|severity)
149    my $name = shift;
150    my %alts = (
151	'category' => {
152	    'default' => 'core',
153	    'ok'      => 'install',
154	    # Inevitably some of these will end up in RT whatever we do:
155	    'thanks'  => 'thanks',
156	    'opts'    => [qw(core docs install library utilities)], # patch, notabug
157	},
158	'severity' => {
159	    'default' => 'low',
160	    'ok'      => 'none',
161	    'thanks'  => 'none',
162	    'opts'    => [qw(critical high medium low wishlist none)], # zero
163	},
164    );
165    die "Invalid alternative ($name) requested\n" unless grep(/^$name$/, keys %alts);
166    my $alt = "";
167    my $what = $ok || $thanks;
168    if ($what) {
169	$alt = $alts{$name}{$what};
170    } else {
171 	my @alts = @{$alts{$name}{'opts'}};
172    print "\n\n";
173	paraprint <<EOF;
174Please pick a $name from the following list:
175
176    @alts
177EOF
178	my $err = 0;
179	do {
180	    if ($err++ > 5) {
181		die "Invalid $name: aborting.\n";
182	    }
183        $alt = _prompt('', "\u$name", $alts{$name}{'default'});
184		$alt ||= $alts{$name}{'default'};
185	} while !((($alt) = grep(/^$alt/i, @alts)));
186    }
187    lc $alt;
188}
189
190sub HELP_MESSAGE { Help(); exit; }
191sub VERSION_MESSAGE { print "perlbug version $VERSION\n"; }
192
193sub Init {
194    # -------- Setup --------
195
196    $Is_MSWin32 = $^O eq 'MSWin32';
197    $Is_VMS = $^O eq 'VMS';
198    $Is_Linux = lc($^O) eq 'linux';
199    $Is_OpenBSD = lc($^O) eq 'openbsd';
200
201    # perlbug address
202    $bugaddress = 'perlbug@perl.org';
203
204    # Test address
205    $testaddress = 'perlbug-test@perl.org';
206
207    # Thanks address
208    $thanksaddress = 'perl-thanks@perl.org';
209
210    # Defaults if getopts fails.
211    $address = (basename ($0) =~ /^perlthanks/i) ? $thanksaddress : $bugaddress;
212    $cc = $::Config{'perladmin'} || $::Config{'cf_email'} || $::Config{'cf_by'} || '';
213
214    HELP_MESSAGE() unless getopts("Adhva:s:b:f:F:r:e:SCc:to:n:T:p:", \%opt);
215
216    # This comment is needed to notify metaconfig that we are
217    # using the $perladmin, $cf_by, and $cf_time definitions.
218    # -------- Configuration ---------
219
220    if (basename ($0) =~ /^perlthanks/i) {
221	# invoked as perlthanks
222	$opt{T} = 1;
223	$opt{C} = 1; # don't send a copy to the local admin
224    }
225
226    if ($opt{T}) {
227	$thanks = 'thanks';
228    }
229
230    $progname = $thanks ? 'perlthanks' : 'perlbug';
231    # Target address
232    $address = $opt{a} || ($opt{t} ? $testaddress
233			    : $thanks ? $thanksaddress : $bugaddress);
234
235    # Users address, used in message and in From and Reply-To headers
236    $from = $opt{r} || "";
237
238    # Include verbose configuration information
239    $verbose = $opt{v} || 0;
240
241    # Subject of bug-report message
242    $subject = $opt{s} || "";
243
244    # Send a file
245    $usefile = ($opt{f} || 0);
246
247    # File to send as report
248    $file = $opt{f} || "";
249
250    # We have one or more attachments
251    $have_attachment = ($opt{p} || 0);
252    $mime_boundary = ('-' x 12) . "$VERSION.perlbug" if $have_attachment;
253
254    # Comma-separated list of attachments
255    $attachments = $opt{p} || "";
256    $has_patch = 0; # TBD based on file type
257
258    for my $attachment (split /\s*,\s*/, $attachments) {
259        unless (-f $attachment && -r $attachment) {
260            die "The attachment $attachment is not a readable file: $!\n";
261        }
262        $has_patch = 1 if $attachment =~ m/\.(patch|diff)$/;
263    }
264
265    # File to output to
266    $outfile = $opt{F} || "";
267
268    # Body of report
269    $body = $opt{b} || "";
270
271    # Editor
272    $ed = $opt{e} || $ENV{VISUAL} || $ENV{EDITOR} || $ENV{EDIT}
273	|| ($Is_VMS && "edit/tpu")
274	|| ($Is_MSWin32 && "notepad")
275	|| "vi";
276
277    # Not OK - provide build failure template by finessing OK report
278    if ($opt{n}) {
279	if (substr($opt{n}, 0, 2) eq 'ok' )	{
280	    $opt{o} = substr($opt{n}, 1);
281	} else {
282	    Help();
283	    exit();
284	}
285    }
286
287    # OK - send "OK" report for build on this system
288    $ok = '';
289    if ($opt{o}) {
290	if ($opt{o} eq 'k' or $opt{o} eq 'kay') {
291	    my $age = time - $patchlevel_date;
292	    if ($opt{o} eq 'k' and $age > 60 * 24 * 60 * 60 ) {
293		my $date = localtime $patchlevel_date;
294		print <<"EOF";
295"perlbug -ok" and "perlbug -nok" do not report on Perl versions which
296are more than 60 days old.  This Perl version was constructed on
297$date.  If you really want to report this, use
298"perlbug -okay" or "perlbug -nokay".
299EOF
300		exit();
301	    }
302	    # force these options
303	    unless ($opt{n}) {
304		$opt{S} = 1; # don't prompt for send
305		$opt{b} = 1; # we have a body
306		$body = "Perl reported to build OK on this system.\n";
307	    }
308	    $opt{C} = 1; # don't send a copy to the local admin
309	    $opt{s} = 1; # we have a subject line
310	    $subject = ($opt{n} ? 'Not ' : '')
311		    . "OK: perl $perl_version ${patch_tags}on"
312		    ." $::Config{'archname'} $::Config{'osvers'} $subject";
313	    $ok = 'ok';
314	} else {
315	    Help();
316	    exit();
317	}
318    }
319
320    # Possible administrator addresses, in order of confidence
321    # (Note that cf_email is not mentioned to metaconfig, since
322    # we don't really want it. We'll just take it if we have to.)
323    #
324    # This has to be after the $ok stuff above because of the way
325    # that $opt{C} is forced.
326    $cc = $opt{C} ? "" : (
327	$opt{c} || $::Config{'perladmin'}
328	|| $::Config{'cf_email'} || $::Config{'cf_by'}
329    );
330
331    if ($::HaveUtil) {
332		$domain = Mail::Util::maildomain();
333    } elsif ($Is_MSWin32) {
334		$domain = $ENV{'USERDOMAIN'};
335    } else {
336		require Sys::Hostname;
337		$domain = Sys::Hostname::hostname();
338    }
339
340    # Message-Id - rjsf
341    $messageid = "<$::Config{'version'}_${$}_".time."\@$domain>";
342
343    # My username
344    $me = $Is_MSWin32 ? $ENV{'USERNAME'}
345	    : $^O eq 'os2' ? $ENV{'USER'} || $ENV{'LOGNAME'}
346	    : eval { getpwuid($<) };	# May be missing
347
348    $from = $::Config{'cf_email'}
349       if !$from && $::Config{'cf_email'} && $::Config{'cf_by'} && $me &&
350               ($me eq $::Config{'cf_by'});
351} # sub Init
352
353sub Query {
354    # Explain what perlbug is
355    unless ($ok) {
356	if ($thanks) {
357	    paraprint <<'EOF';
358This program provides an easy way to send a thank-you message back to the
359authors and maintainers of perl.
360
361If you wish to submit a bug report, please run it without the -T flag.
362EOF
363	} else {
364	    paraprint <<"EOF";
365This program provides an easy way to create a message reporting a
366bug in the core perl distribution (along with tests or patches)
367to the volunteers who maintain perl at $address.  To send a thank-you
368note to $thanksaddress instead of a bug report, please use the -T flag.
369
370Please do not use $0 to send test messages, test whether perl
371works, or to report bugs in perl modules from CPAN.
372
373Suggestions for how to find help using Perl can be found at
374http://perldoc.perl.org/perlcommunity.html
375EOF
376	}
377    }
378
379    # Prompt for subject of message, if needed
380
381    if ($subject && TrivialSubject($subject)) {
382	$subject = '';
383    }
384
385    unless ($subject) {
386	    print
387"First of all, please provide a subject for the message.\n";
388	if ( not $thanks)  {
389	    paraprint <<EOF;
390This should be a concise description of your bug or problem
391which will help the volunteers working to improve perl to categorize
392and resolve the issue.  Be as specific and descriptive as
393you can. A subject like "perl bug" or "perl problem" will make it
394much less likely that your issue gets the attention it deserves.
395EOF
396	}
397
398	my $err = 0;
399	do {
400        $subject = _prompt('','Subject');
401	    if ($err++ == 5) {
402		if ($thanks) {
403		    $subject = 'Thanks for Perl';
404		} else {
405		    die "Aborting.\n";
406		}
407	    }
408	} while (TrivialSubject($subject));
409    }
410    $subject = '[PATCH] ' . $subject
411        if $has_patch && ($subject !~ m/^\[PATCH/i);
412
413    # Prompt for return address, if needed
414    unless ($opt{r}) {
415	# Try and guess return address
416	my $guess;
417
418	$guess = $ENV{'REPLY-TO'} || $ENV{'REPLYTO'} || $ENV{'EMAIL'}
419	    || $from || '';
420
421	unless ($guess) {
422		# move $domain to where we can use it elsewhere
423        if ($domain) {
424		if ($Is_VMS && !$::Config{'d_socket'}) {
425		    $guess = "$domain\:\:$me";
426		} else {
427		    $guess = "$me\@$domain" if $domain;
428		}
429	    }
430	}
431
432	if ($guess) {
433	    unless ($ok) {
434		paraprint <<EOF;
435Perl's developers may need your email address to contact you for
436further information about your issue or to inform you when it is
437resolved.  If the default shown is not your email address, please
438correct it.
439EOF
440	    }
441	} else {
442	    paraprint <<EOF;
443Please enter your full internet email address so that Perl's
444developers can contact you with questions about your issue or to
445inform you that it has been resolved.
446EOF
447	}
448
449	if ($ok && $guess) {
450	    # use it
451	    $from = $guess;
452	} else {
453	    # verify it
454        $from = _prompt('','Your address',$guess);
455	    $from = $guess if $from eq '';
456	}
457    }
458
459    if ($from eq $cc or $me eq $cc) {
460	# Try not to copy ourselves
461	$cc = "yourself";
462    }
463
464    # Prompt for administrator address, unless an override was given
465    if( !$opt{C} and !$opt{c} ) {
466	my $description =  <<EOF;
467$0 can send a copy of this report to your local perl
468administrator.  If the address below is wrong, please correct it,
469or enter 'none' or 'yourself' to not send a copy.
470EOF
471	my $entry = _prompt($description, "Local perl administrator", $cc);
472
473	if ($entry ne "") {
474	    $cc = $entry;
475	    $cc = '' if $me eq $cc;
476	}
477    }
478
479    $cc = '' if $cc =~ /^(none|yourself|me|myself|ourselves)$/i;
480    if ($cc) {
481        $andcc = " and $cc"
482    } else {
483        $andcc = ''
484    }
485
486    # Prompt for editor, if no override is given
487editor:
488    unless ($opt{e} || $opt{f} || $opt{b}) {
489
490    my $description;
491
492	chomp (my $common_end = <<"EOF");
493You will probably want to use a text editor to enter the body of
494your report. If "$ed" is the editor you want to use, then just press
495Enter, otherwise type in the name of the editor you would like to
496use.
497
498If you have already composed the body of your report, you may enter
499"file", and $0 will prompt you to enter the name of the file
500containing your report.
501EOF
502
503	if ($thanks) {
504	    $description = <<"EOF";
505It's now time to compose your thank-you message.
506
507Some information about your local perl configuration will automatically
508be included at the end of your message, because we're curious about
509the different ways that people build and use perl. If you'd rather
510not share this information, you're welcome to delete it.
511
512$common_end
513EOF
514	} else {
515	    $description =  <<"EOF";
516It's now time to compose your bug report. Try to make the report
517concise but descriptive. Please include any detail which you think
518might be relevant or might help the volunteers working to improve
519perl. If you are reporting something that does not work as you think
520it should, please try to include examples of the actual result and of
521what you expected.
522
523Some information about your local perl configuration will automatically
524be included at the end of your report. If you are using an unusual
525version of perl, it would be useful if you could confirm that you
526can replicate the problem on a standard build of perl as well.
527
528$common_end
529EOF
530	}
531
532    my $entry = _prompt($description, "Editor", $ed);
533	$usefile = 0;
534	if ($entry eq "file") {
535	    $usefile = 1;
536	} elsif ($entry ne "") {
537	    $ed = $entry;
538	}
539    }
540    if ($::HaveCoreList && !$ok && !$thanks) {
541	my $description =  <<EOF;
542If your bug is about a Perl module rather than a core language
543feature, please enter its name here. If it's not, just hit Enter
544to skip this question.
545EOF
546
547    my $entry = '';
548	while ($entry eq '') {
549        $entry = _prompt($description, 'Module');
550	    my $first_release = Module::CoreList->first_release($entry);
551	    if ($entry and not $first_release) {
552		paraprint <<EOF;
553$entry is not a "core" Perl module. Please check that you entered
554its name correctly. If it is correct, quit this program, try searching
555for $entry on http://rt.cpan.org, and report your issue there.
556EOF
557
558            $entry = '';
559	} elsif (my $bug_tracker = $Module::CoreList::bug_tracker{$entry}) {
560		paraprint <<"EOF";
561$entry included with core Perl is copied directly from the CPAN distribution.
562Please report bugs in $entry directly to its maintainers using $bug_tracker
563EOF
564            $entry = '';
565        } elsif ($entry) {
566	        $category ||= 'library';
567	        $report_about_module = $entry;
568            last;
569        } else {
570            last;
571        }
572	}
573    }
574
575    # Prompt for category of bug
576    $category ||= ask_for_alternatives('category');
577
578    # Prompt for severity of bug
579    $severity ||= ask_for_alternatives('severity');
580
581    # Generate scratch file to edit report in
582    $filename = filename();
583
584    # Prompt for file to read report from, if needed
585    if ($usefile and !$file) {
586filename:
587	my $description = <<EOF;
588What is the name of the file that contains your report?
589EOF
590	my $entry = _prompt($description, "Filename");
591
592	if ($entry eq "") {
593	    paraprint <<EOF;
594It seems you didn't enter a filename. Please choose to use a text
595editor or enter a filename.
596EOF
597	    goto editor;
598	}
599
600	unless (-f $entry and -r $entry) {
601	    paraprint <<EOF;
602'$entry' doesn't seem to be a readable file.  You may have mistyped
603its name or may not have permission to read it.
604
605If you don't want to use a file as the content of your report, just
606hit Enter and you'll be able to select a text editor instead.
607EOF
608	    goto filename;
609	}
610	$file = $entry;
611    }
612
613    # Generate report
614    open(REP, '>:raw', $filename) or die "Unable to create report file '$filename': $!\n";
615    binmode(REP, ':raw :crlf') if $Is_MSWin32;
616
617    my $reptype = !$ok ? ($thanks ? 'thank-you' : 'bug')
618	: $opt{n} ? "build failure" : "success";
619
620    print REP <<EOF;
621This is a $reptype report for perl from $from,
622generated with the help of perlbug $VERSION running under perl $perl_version.
623
624EOF
625
626    if ($body) {
627	print REP $body;
628    } elsif ($usefile) {
629	open(F, '<:raw', $file)
630		or die "Unable to read report file from '$file': $!\n";
631	binmode(F, ':raw :crlf') if $Is_MSWin32;
632	while (<F>) {
633	    print REP $_
634	}
635	close(F) or die "Error closing '$file': $!";
636    } else {
637	if ($thanks) {
638	    print REP <<'EOF';
639
640-----------------------------------------------------------------
641[Please enter your thank-you message here]
642
643
644
645[You're welcome to delete anything below this line]
646-----------------------------------------------------------------
647EOF
648	} else {
649	    print REP <<'EOF';
650
651-----------------------------------------------------------------
652[Please describe your issue here]
653
654
655
656[Please do not change anything below this line]
657-----------------------------------------------------------------
658EOF
659	}
660    }
661    Dump(*REP);
662    close(REP) or die "Error closing report file: $!";
663
664    # Set up an initial report fingerprint so we can compare it later
665    _fingerprint_lines_in_report();
666
667} # sub Query
668
669sub Dump {
670    local(*OUT) = @_;
671
672    # these won't have been set if run with -d
673    $category ||= 'core';
674    $severity ||= 'low';
675
676    print OUT <<EFF;
677---
678Flags:
679    category=$category
680    severity=$severity
681EFF
682
683    if ($has_patch) {
684        print OUT <<EFF;
685    Type=Patch
686    PatchStatus=HasPatch
687EFF
688    }
689
690    if ($report_about_module ) {
691        print OUT <<EFF;
692    module=$report_about_module
693EFF
694    }
695    if ($opt{A}) {
696	print OUT <<EFF;
697    ack=no
698EFF
699    }
700    print OUT <<EFF;
701---
702EFF
703    print OUT "This perlbug was built using Perl $config_tag1\n",
704	    "It is being executed now by  Perl $config_tag2.\n\n"
705	if $config_tag2 ne $config_tag1;
706
707    print OUT <<EOF;
708Site configuration information for perl $perl_version:
709
710EOF
711    if ($::Config{cf_by} and $::Config{cf_time}) {
712	print OUT "Configured by $::Config{cf_by} at $::Config{cf_time}.\n\n";
713    }
714    print OUT Config::myconfig;
715
716    if (@patches) {
717	print OUT join "\n    ", "Locally applied patches:", @patches;
718	print OUT "\n";
719    };
720
721    print OUT <<EOF;
722
723---
724\@INC for perl $perl_version:
725EOF
726    for my $i (@INC) {
727	print OUT "    $i\n";
728    }
729
730    print OUT <<EOF;
731
732---
733Environment for perl $perl_version:
734EOF
735    my @env =
736        qw(PATH LD_LIBRARY_PATH LANG PERL_BADLANG SHELL HOME LOGDIR LANGUAGE);
737    push @env, $Config{ldlibpthname} if $Config{ldlibpthname} ne '';
738    push @env, grep /^(?:PERL|LC_|LANG|CYGWIN)/, keys %ENV;
739    my %env;
740    @env{@env} = @env;
741    for my $env (sort keys %env) {
742	print OUT "    $env",
743		exists $ENV{$env} ? "=$ENV{$env}" : ' (unset)',
744		"\n";
745    }
746    if ($verbose) {
747	print OUT "\nComplete configuration data for perl $perl_version:\n\n";
748	my $value;
749	foreach (sort keys %::Config) {
750	    $value = $::Config{$_};
751	    $value = '' unless defined $value;
752	    $value =~ s/'/\\'/g;
753	    print OUT "$_='$value'\n";
754	}
755    }
756} # sub Dump
757
758sub Edit {
759    # Edit the report
760    if ($usefile || $body) {
761	my $description = "Please make sure that the name of the editor you want to use is correct.";
762	my $entry = _prompt($description, 'Editor', $ed);
763	$ed = $entry unless $entry eq '';
764    }
765
766    _edit_file($ed) unless $running_noninteractively;
767}
768
769sub _edit_file {
770    my $editor = shift;
771
772    my $report_written = 0;
773
774    while ( !$report_written ) {
775        my $exit_status = system("$editor $filename");
776        if ($exit_status) {
777            my $desc = <<EOF;
778The editor you chose ('$editor') could not be run!
779
780If you mistyped its name, please enter it now, otherwise just press Enter.
781EOF
782            my $entry = _prompt( $desc, 'Editor', $editor );
783            if ( $entry ne "" ) {
784                $editor = $entry;
785                next;
786            } else {
787                paraprint <<EOF;
788You may want to save your report to a file, so you can edit and
789mail it later.
790EOF
791                return;
792            }
793        }
794        return if ( $ok and not $opt{n} ) || $body;
795
796        # Check that we have a report that has some, eh, report in it.
797
798        unless ( _fingerprint_lines_in_report() ) {
799            my $description = <<EOF;
800It looks like you didn't enter a report. You may [r]etry your edit
801or [c]ancel this report.
802EOF
803            my $action = _prompt( $description, "Action (Retry/Cancel) " );
804            if ( $action =~ /^[re]/i ) {    # <R>etry <E>dit
805                next;
806            } elsif ( $action =~ /^[cq]/i ) {    # <C>ancel, <Q>uit
807                Cancel();                        # cancel exits
808            }
809        }
810        # Ok. the user did what they needed to;
811        return;
812
813    }
814}
815
816
817sub Cancel {
818    1 while unlink($filename);  # remove all versions under VMS
819    print "\nQuitting without sending your message.\n";
820    exit(0);
821}
822
823sub NowWhat {
824    # Report is done, prompt for further action
825    if( !$opt{S} ) {
826	while(1) {
827	    my $menu = <<EOF;
828
829
830You have finished composing your message. At this point, you have
831a few options. You can:
832
833    * [Se]nd the message to $address$andcc,
834    * [D]isplay the message on the screen,
835    * [R]e-edit the message
836    * Display or change the message's [su]bject
837    * Save the message to a [f]ile to mail at another time
838    * [Q]uit without sending a message
839
840EOF
841      retry:
842        print $menu;
843	    my $action =  _prompt('', "Action (Send/Display/Edit/Subject/Save to File)",
844	        $opt{t} ? 'q' : '');
845        print "\n";
846	    if ($action =~ /^(f|sa)/i) { # <F>ile/<Sa>ve
847            if ( SaveMessage() ) { exit }
848	    } elsif ($action =~ /^(d|l|sh)/i ) { # <D>isplay, <L>ist, <Sh>ow
849		# Display the message
850		print _read_report($filename);
851		if ($have_attachment) {
852		    print "\n\n---\nAttachment(s):\n";
853		    for my $att (split /\s*,\s*/, $attachments) { print "    $att\n"; }
854		}
855	    } elsif ($action =~ /^su/i) { # <Su>bject
856		my $reply = _prompt( "Subject: $subject", "If the above subject is fine, press Enter. Otherwise, type a replacement now\nSubject");
857		if ($reply ne '') {
858		    unless (TrivialSubject($reply)) {
859			$subject = $reply;
860			print "Subject: $subject\n";
861		    }
862		}
863	    } elsif ($action =~ /^se/i) { # <S>end
864		# Send the message
865		my $reply =  _prompt( "Are you certain you want to send this message?", 'Please type "yes" if you are','no');
866		if ($reply =~ /^yes$/) {
867		    last;
868		} else {
869		    paraprint <<EOF;
870You didn't type "yes", so your message has not yet been sent.
871EOF
872		}
873	    } elsif ($action =~ /^[er]/i) { # <E>dit, <R>e-edit
874		# edit the message
875		Edit();
876	    } elsif ($action =~ /^[qc]/i) { # <C>ancel, <Q>uit
877		Cancel();
878	    } elsif ($action =~ /^s/i) {
879		paraprint <<EOF;
880The command you entered was ambiguous. Please type "send", "save" or "subject".
881EOF
882	    }
883	}
884    }
885} # sub NowWhat
886
887sub TrivialSubject {
888    my $subject = shift;
889    if ($subject =~
890	/^(y(es)?|no?|help|perl( (bug|problem))?|bug|problem)$/i ||
891	length($subject) < 4 ||
892	($subject !~ /\s/ && ! $opt{t})) { # non-whitespace is accepted in test mode
893	print "\nThe subject you entered wasn't very descriptive. Please try again.\n\n";
894        return 1;
895    } else {
896	return 0;
897    }
898}
899
900sub SaveMessage {
901    my $file_save = $outfile || "$progname.rep";
902    my $file = _prompt( '', "Name of file to save message in", $file_save );
903    save_message_to_disk($file) || return undef;
904    print "\n";
905    paraprint <<EOF;
906A copy of your message has been saved in '$file' for you to
907send to '$address' with your normal mail client.
908EOF
909}
910
911sub Send {
912
913    # Message has been accepted for transmission -- Send the message
914
915    # on linux certain "mail" implementations won't accept the subject
916    # as "~s subject" and thus the Subject header will be corrupted
917    # so don't use Mail::Send to be safe
918    eval {
919        if ( $::HaveSend && !$Is_Linux && !$Is_OpenBSD ) {
920            _send_message_mailsend();
921        } elsif ($Is_VMS) {
922            _send_message_vms();
923        } else {
924            _send_message_sendmail();
925        }
926    };
927
928    if ( my $error = $@ ) {
929        paraprint <<EOF;
930$0 has detected an error while trying to send your message: $error.
931
932Your message may not have been sent. You will now have a chance to save a copy to disk.
933EOF
934        SaveMessage();
935        return;
936    }
937
938    1 while unlink($filename);    # remove all versions under VMS
939}    # sub Send
940
941sub Help {
942    print <<EOF;
943
944This program is designed to help you generate and send bug reports
945(and thank-you notes) about perl5 and the modules which ship with it.
946
947In most cases, you can just run "$0" interactively from a command
948line without any special arguments and follow the prompts.
949
950Advanced usage:
951
952$0  [-v] [-a address] [-s subject] [-b body | -f inpufile ] [ -F outputfile ]
953    [-r returnaddress] [-e editor] [-c adminaddress | -C] [-S] [-t] [-h]
954    [-p patchfile ]
955$0  [-v] [-r returnaddress] [-A] [-ok | -okay | -nok | -nokay]
956
957
958Options:
959
960  -v    Include Verbose configuration data in the report
961  -f    File containing the body of the report. Use this to
962        quickly send a prepared message.
963  -p    File containing a patch or other text attachment. Separate
964        multiple files with commas.
965  -F    File to output the resulting mail message to, instead of mailing.
966  -S    Send without asking for confirmation.
967  -a    Address to send the report to. Defaults to '$address'.
968  -c    Address to send copy of report to. Defaults to '$cc'.
969  -C    Don't send copy to administrator.
970  -s    Subject to include with the message. You will be prompted
971        if you don't supply one on the command line.
972  -b    Body of the report. If not included on the command line, or
973        in a file with -f, you will get a chance to edit the message.
974  -r    Your return address. The program will ask you to confirm
975        this if you don't give it here.
976  -e    Editor to use.
977  -t    Test mode. The target address defaults to '$testaddress'.
978  -T    Thank-you mode. The target address defaults to '$thanksaddress'.
979  -d    Data mode.  This prints out your configuration data, without mailing
980        anything. You can use this with -v to get more complete data.
981  -A    Don't send a bug received acknowledgement to the return address.
982  -ok   Report successful build on this system to perl porters
983        (use alone or with -v). Only use -ok if *everything* was ok:
984        if there were *any* problems at all, use -nok.
985  -okay As -ok but allow report from old builds.
986  -nok  Report unsuccessful build on this system to perl porters
987        (use alone or with -v). You must describe what went wrong
988        in the body of the report which you will be asked to edit.
989  -nokay As -nok but allow report from old builds.
990  -h    Print this help message.
991
992EOF
993}
994
995sub filename {
996    if ($::HaveTemp) {
997	# Good. Use a secure temp file
998	my ($fh, $filename) = File::Temp::tempfile(UNLINK => 1);
999	close($fh);
1000	return $filename;
1001    } else {
1002	# Bah. Fall back to doing things less securely.
1003	my $dir = File::Spec->tmpdir();
1004	$filename = "bugrep0$$";
1005	$filename++ while -e File::Spec->catfile($dir, $filename);
1006	$filename = File::Spec->catfile($dir, $filename);
1007    }
1008}
1009
1010sub paraprint {
1011    my @paragraphs = split /\n{2,}/, "@_";
1012    for (@paragraphs) {   # implicit local $_
1013	s/(\S)\s*\n/$1 /g;
1014	write;
1015	print "\n";
1016    }
1017}
1018
1019sub _prompt {
1020    my ($explanation, $prompt, $default) = (@_);
1021    if ($explanation) {
1022        print "\n\n";
1023        paraprint $explanation;
1024    }
1025    print $prompt. ($default ? " [$default]" :''). ": ";
1026	my $result = scalar(<>);
1027    return $default if !defined $result; # got eof
1028    chomp($result);
1029	$result =~ s/^\s*(.*?)\s*$/$1/s;
1030    if ($default && $result eq '') {
1031        return $default;
1032    } else {
1033        return $result;
1034    }
1035}
1036
1037sub _build_header {
1038    my %attr = (@_);
1039
1040    my $head = '';
1041    for my $header (keys %attr) {
1042        $head .= "$header: ".$attr{$header}."\n";
1043    }
1044    return $head;
1045}
1046
1047sub _message_headers {
1048    my %headers = ( To => $address, Subject => $subject );
1049    $headers{'Cc'}         = $cc        if ($cc);
1050    $headers{'Message-Id'} = $messageid if ($messageid);
1051    $headers{'Reply-To'}   = $from      if ($from);
1052    $headers{'From'}       = $from      if ($from);
1053    if ($have_attachment) {
1054        $headers{'MIME-Version'} = '1.0';
1055        $headers{'Content-Type'} = qq{multipart/mixed; boundary=\"$mime_boundary\"};
1056    }
1057    return \%headers;
1058}
1059
1060sub _add_body_start {
1061    my $body_start = <<"BODY_START";
1062This is a multi-part message in MIME format.
1063--$mime_boundary
1064Content-Type: text/plain; format=fixed
1065Content-Transfer-Encoding: 8bit
1066
1067BODY_START
1068    return $body_start;
1069}
1070
1071sub _add_attachments {
1072    my $attach = '';
1073    for my $attachment (split /\s*,\s*/, $attachments) {
1074        my $attach_file = basename($attachment);
1075        $attach .= <<"ATTACHMENT";
1076
1077--$mime_boundary
1078Content-Type: text/x-patch; name="$attach_file"
1079Content-Transfer-Encoding: 8bit
1080Content-Disposition: attachment; filename="$attach_file"
1081
1082ATTACHMENT
1083
1084        open my $attach_fh, '<:raw', $attachment
1085            or die "Couldn't open attachment '$attachment': $!\n";
1086        while (<$attach_fh>) { $attach .= $_; }
1087        close($attach_fh) or die "Error closing attachment '$attachment': $!";
1088    }
1089
1090    $attach .= "\n--$mime_boundary--\n";
1091    return $attach;
1092}
1093
1094sub _read_report {
1095    my $fname = shift;
1096    my $content;
1097    open( REP, "<:raw", $fname ) or die "Couldn't open file '$fname': $!\n";
1098    binmode(REP, ':raw :crlf') if $Is_MSWin32;
1099    # wrap long lines to make sure the report gets delivered
1100    local $Text::Wrap::columns = 900;
1101    local $Text::Wrap::huge = 'overflow';
1102    while (<REP>) {
1103        if ($::HaveWrap && /\S/) { # wrap() would remove empty lines
1104            $content .= Text::Wrap::wrap(undef, undef, $_);
1105        } else {
1106            $content .= $_;
1107        }
1108    }
1109    close(REP) or die "Error closing report file '$fname': $!";
1110    return $content;
1111}
1112
1113sub build_complete_message {
1114    my $content = _build_header(%{_message_headers()}) . "\n\n";
1115    $content .= _add_body_start() if $have_attachment;
1116    $content .= _read_report($filename);
1117    $content .= _add_attachments() if $have_attachment;
1118    return $content;
1119}
1120
1121sub save_message_to_disk {
1122    my $file = shift;
1123
1124        if (-e $file) {
1125            my $response = _prompt( '', "Overwrite existing '$file'", 'n' );
1126            return undef unless $response =~ / yes | y /xi;
1127        }
1128        open OUTFILE, '>:raw', $file or do { warn  "Couldn't open '$file': $!\n"; return undef};
1129        binmode(OUTFILE, ':raw :crlf') if $Is_MSWin32;
1130
1131        print OUTFILE build_complete_message();
1132        close(OUTFILE) or do { warn  "Error closing $file: $!"; return undef };
1133	    print "\nMessage saved.\n";
1134        return 1;
1135}
1136
1137sub _send_message_vms {
1138
1139    my $mail_from  = $from;
1140    my $rcpt_to_to = $address;
1141    my $rcpt_to_cc = $cc;
1142
1143    map { $_ =~ s/^[^<]*<//;
1144          $_ =~ s/>[^>]*//; } ($mail_from, $rcpt_to_to, $rcpt_to_cc);
1145
1146    if ( open my $sff_fh, '|-:raw', 'MCR TCPIP$SYSTEM:TCPIP$SMTP_SFF.EXE SYS$INPUT:' ) {
1147        print $sff_fh "MAIL FROM:<$mail_from>\n";
1148        print $sff_fh "RCPT TO:<$rcpt_to_to>\n";
1149        print $sff_fh "RCPT TO:<$rcpt_to_cc>\n" if $rcpt_to_cc;
1150        print $sff_fh "DATA\n";
1151        print $sff_fh build_complete_message();
1152        my $success = close $sff_fh;
1153        if ($success ) {
1154            print "\nMessage sent\n";
1155            return;
1156        }
1157    }
1158    die "Mail transport failed (leaving bug report in $filename): $^E\n";
1159}
1160
1161sub _send_message_mailsend {
1162    my $msg = Mail::Send->new();
1163    my %headers = %{_message_headers()};
1164    for my $key ( keys %headers) {
1165        $msg->add($key => $headers{$key});
1166    }
1167
1168    $fh = $msg->open;
1169    binmode($fh, ':raw');
1170    print $fh _add_body_start() if $have_attachment;
1171    print $fh _read_report($filename);
1172    print $fh _add_attachments() if $have_attachment;
1173    $fh->close or die "Error sending mail: $!";
1174
1175    print "\nMessage sent.\n";
1176}
1177
1178sub _probe_for_sendmail {
1179    my $sendmail = "";
1180    for (qw(/usr/lib/sendmail /usr/sbin/sendmail /usr/ucblib/sendmail)) {
1181        $sendmail = $_, last if -e $_;
1182    }
1183    if ( $^O eq 'os2' and $sendmail eq "" ) {
1184        my $path = $ENV{PATH};
1185        $path =~ s:\\:/:;
1186        my @path = split /$Config{'path_sep'}/, $path;
1187        for (@path) {
1188            $sendmail = "$_/sendmail",     last if -e "$_/sendmail";
1189            $sendmail = "$_/sendmail.exe", last if -e "$_/sendmail.exe";
1190        }
1191    }
1192    return $sendmail;
1193}
1194
1195sub _send_message_sendmail {
1196    my $sendmail = _probe_for_sendmail();
1197    unless ($sendmail) {
1198        my $message_start = !$Is_Linux && !$Is_OpenBSD ? <<'EOT' : <<'EOT';
1199It appears that there is no program which looks like "sendmail" on
1200your system and that the Mail::Send library from CPAN isn't available.
1201EOT
1202It appears that there is no program which looks like "sendmail" on
1203your system.
1204EOT
1205        paraprint(<<"EOF"), die "\n";
1206$message_start
1207Because of this, there's no easy way to automatically send your
1208message.
1209
1210A copy of your message has been saved in '$filename' for you to
1211send to '$address' with your normal mail client.
1212EOF
1213    }
1214
1215    open( SENDMAIL, "|-:raw", $sendmail, "-t", "-oi", "-f", $from )
1216        || die "'|$sendmail -t -oi -f $from' failed: $!";
1217    print SENDMAIL build_complete_message();
1218    if ( close(SENDMAIL) ) {
1219        print "\nMessage sent\n";
1220    } else {
1221        warn "\nSendmail returned status '", $? >> 8, "'\n";
1222    }
1223}
1224
1225
1226
1227# a strange way to check whether any significant editing
1228# has been done: check whether any new non-empty lines
1229# have been added.
1230
1231sub _fingerprint_lines_in_report {
1232    my $new_lines = 0;
1233    # read in the report template once so that
1234    # we can track whether the user does any editing.
1235    # yes, *all* whitespace is ignored.
1236
1237    open(REP, '<:raw', $filename) or die "Unable to open report file '$filename': $!\n";
1238    binmode(REP, ':raw :crlf') if $Is_MSWin32;
1239    while (my $line = <REP>) {
1240        $line =~ s/\s+//g;
1241        $new_lines++ if (!$REP{$line});
1242
1243    }
1244    close(REP) or die "Error closing report file '$filename': $!";
1245    # returns the number of lines with content that wasn't there when last we looked
1246    return $new_lines;
1247}
1248
1249
1250
1251format STDOUT =
1252^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
1253$_
1254.
1255
1256__END__
1257
1258=head1 NAME
1259
1260perlbug - how to submit bug reports on Perl
1261
1262=head1 SYNOPSIS
1263
1264B<perlbug>
1265
1266B<perlbug> S<[ B<-v> ]> S<[ B<-a> I<address> ]> S<[ B<-s> I<subject> ]>
1267S<[ B<-b> I<body> | B<-f> I<inputfile> ]> S<[ B<-F> I<outputfile> ]>
1268S<[ B<-r> I<returnaddress> ]>
1269S<[ B<-e> I<editor> ]> S<[ B<-c> I<adminaddress> | B<-C> ]>
1270S<[ B<-S> ]> S<[ B<-t> ]>  S<[ B<-d> ]>  S<[ B<-A> ]>  S<[ B<-h> ]> S<[ B<-T> ]>
1271
1272B<perlbug> S<[ B<-v> ]> S<[ B<-r> I<returnaddress> ]>
1273 S<[ B<-A> ]> S<[ B<-ok> | B<-okay> | B<-nok> | B<-nokay> ]>
1274
1275=head1 DESCRIPTION
1276
1277
1278This program is designed to help you generate bug reports
1279(and thank-you notes) about perl5 and the modules which ship with it.
1280
1281In most cases, you can just run it interactively from a command
1282line without any special arguments and follow the prompts.
1283
1284If you have found a bug with a non-standard port (one that was not
1285part of the I<standard distribution>), a binary distribution, or a
1286non-core module (such as Tk, DBI, etc), then please see the
1287documentation that came with that distribution to determine the
1288correct place to report bugs.
1289
1290Bug reports should be submitted to the GitHub issue tracker at
1291L<https://github.com/Perl/perl5/issues>. The B<perlbug@perl.org>
1292address no longer automatically opens tickets. You can use this tool
1293to compose your report and save it to a file which you can then submit
1294to the issue tracker.
1295
1296In extreme cases, B<perlbug> may not work well enough on your system
1297to guide you through composing a bug report. In those cases, you
1298may be able to use B<perlbug -d> or B<perl -V> to get system
1299configuration information to include in your issue report.
1300
1301
1302When reporting a bug, please run through this checklist:
1303
1304=over 4
1305
1306=item What version of Perl you are running?
1307
1308Type C<perl -v> at the command line to find out.
1309
1310=item Are you running the latest released version of perl?
1311
1312Look at http://www.perl.org/ to find out.  If you are not using the
1313latest released version, please try to replicate your bug on the
1314latest stable release.
1315
1316Note that reports about bugs in old versions of Perl, especially
1317those which indicate you haven't also tested the current stable
1318release of Perl, are likely to receive less attention from the
1319volunteers who build and maintain Perl than reports about bugs in
1320the current release.
1321
1322This tool isn't appropriate for reporting bugs in any version
1323prior to Perl 5.0.
1324
1325=item Are you sure what you have is a bug?
1326
1327A significant number of the bug reports we get turn out to be
1328documented features in Perl.  Make sure the issue you've run into
1329isn't intentional by glancing through the documentation that comes
1330with the Perl distribution.
1331
1332Given the sheer volume of Perl documentation, this isn't a trivial
1333undertaking, but if you can point to documentation that suggests
1334the behaviour you're seeing is I<wrong>, your issue is likely to
1335receive more attention. You may want to start with B<perldoc>
1336L<perltrap> for pointers to common traps that new (and experienced)
1337Perl programmers run into.
1338
1339If you're unsure of the meaning of an error message you've run
1340across, B<perldoc> L<perldiag> for an explanation.  If the message
1341isn't in perldiag, it probably isn't generated by Perl.  You may
1342have luck consulting your operating system documentation instead.
1343
1344If you are on a non-UNIX platform B<perldoc> L<perlport>, as some
1345features may be unimplemented or work differently.
1346
1347You may be able to figure out what's going wrong using the Perl
1348debugger.  For information about how to use the debugger B<perldoc>
1349L<perldebug>.
1350
1351=item Do you have a proper test case?
1352
1353The easier it is to reproduce your bug, the more likely it will be
1354fixed -- if nobody can duplicate your problem, it probably won't be
1355addressed.
1356
1357A good test case has most of these attributes: short, simple code;
1358few dependencies on external commands, modules, or libraries; no
1359platform-dependent code (unless it's a platform-specific bug);
1360clear, simple documentation.
1361
1362A good test case is almost always a good candidate to be included in
1363Perl's test suite.  If you have the time, consider writing your test case so
1364that it can be easily included into the standard test suite.
1365
1366=item Have you included all relevant information?
1367
1368Be sure to include the B<exact> error messages, if any.
1369"Perl gave an error" is not an exact error message.
1370
1371If you get a core dump (or equivalent), you may use a debugger
1372(B<dbx>, B<gdb>, etc) to produce a stack trace to include in the bug
1373report.
1374
1375NOTE: unless your Perl has been compiled with debug info
1376(often B<-g>), the stack trace is likely to be somewhat hard to use
1377because it will most probably contain only the function names and not
1378their arguments.  If possible, recompile your Perl with debug info and
1379reproduce the crash and the stack trace.
1380
1381=item Can you describe the bug in plain English?
1382
1383The easier it is to understand a reproducible bug, the more likely
1384it will be fixed.  Any insight you can provide into the problem
1385will help a great deal.  In other words, try to analyze the problem
1386(to the extent you can) and report your discoveries.
1387
1388=item Can you fix the bug yourself?
1389
1390If so, that's great news; bug reports with patches are likely to
1391receive significantly more attention and interest than those without
1392patches.  Please submit your patch via the GitHub Pull Request workflow
1393as described in B<perldoc> L<perlhack>.  You may also send patches to
1394B<perl5-porters@perl.org>.  When sending a patch, create it using
1395C<git format-patch> if possible, though a unified diff created with
1396C<diff -pu> will do nearly as well.
1397
1398Your patch may be returned with requests for changes, or requests for more
1399detailed explanations about your fix.
1400
1401Here are a few hints for creating high-quality patches:
1402
1403Make sure the patch is not reversed (the first argument to diff is
1404typically the original file, the second argument your changed file).
1405Make sure you test your patch by applying it with C<git am> or the
1406C<patch> program before you send it on its way.  Try to follow the
1407same style as the code you are trying to patch.  Make sure your patch
1408really does work (C<make test>, if the thing you're patching is covered
1409by Perl's test suite).
1410
1411=item Can you use C<perlbug> to submit a thank-you note?
1412
1413Yes, you can do this by using the C<-T> option.
1414Thank-you notes are good. It makes people
1415smile.
1416
1417=back
1418
1419Please make your issue title informative.  "a bug" is not informative.
1420Neither is "perl crashes" nor is "HELP!!!".  These don't help.  A compact
1421description of what's wrong is fine.
1422
1423Having done your bit, please be prepared to wait, to be told the
1424bug is in your code, or possibly to get no reply at all.  The
1425volunteers who maintain Perl are busy folks, so if your problem is
1426an obvious bug in your own code, is difficult to understand or is
1427a duplicate of an existing report, you may not receive a personal
1428reply.
1429
1430If it is important to you that your bug be fixed, do monitor the
1431issue tracker (you will be subscribed to notifications for issues you
1432submit or comment on) and the commit logs to development
1433versions of Perl, and encourage the maintainers with kind words or
1434offers of frosty beverages.  (Please do be kind to the maintainers.
1435Harassing or flaming them is likely to have the opposite effect of the
1436one you want.)
1437
1438Feel free to update the ticket about your bug on http://rt.perl.org
1439if a new version of Perl is released and your bug is still present.
1440
1441=head1 OPTIONS
1442
1443=over 8
1444
1445=item B<-a>
1446
1447Address to send the report to.  Defaults to B<perlbug@perl.org>.
1448
1449=item B<-A>
1450
1451Don't send a bug received acknowledgement to the reply address.
1452Generally it is only a sensible to use this option if you are a
1453perl maintainer actively watching perl porters for your message to
1454arrive.
1455
1456=item B<-b>
1457
1458Body of the report.  If not included on the command line, or
1459in a file with B<-f>, you will get a chance to edit the message.
1460
1461=item B<-C>
1462
1463Don't send copy to administrator.
1464
1465=item B<-c>
1466
1467Address to send copy of report to.  Defaults to the address of the
1468local perl administrator (recorded when perl was built).
1469
1470=item B<-d>
1471
1472Data mode (the default if you redirect or pipe output).  This prints out
1473your configuration data, without mailing anything.  You can use this
1474with B<-v> to get more complete data.
1475
1476=item B<-e>
1477
1478Editor to use.
1479
1480=item B<-f>
1481
1482File containing the body of the report.  Use this to quickly send a
1483prepared message.
1484
1485=item B<-F>
1486
1487File to output the results to instead of sending as an email. Useful
1488particularly when running perlbug on a machine with no direct internet
1489connection.
1490
1491=item B<-h>
1492
1493Prints a brief summary of the options.
1494
1495=item B<-ok>
1496
1497Report successful build on this system to perl porters. Forces B<-S>
1498and B<-C>. Forces and supplies values for B<-s> and B<-b>. Only
1499prompts for a return address if it cannot guess it (for use with
1500B<make>). Honors return address specified with B<-r>.  You can use this
1501with B<-v> to get more complete data.   Only makes a report if this
1502system is less than 60 days old.
1503
1504=item B<-okay>
1505
1506As B<-ok> except it will report on older systems.
1507
1508=item B<-nok>
1509
1510Report unsuccessful build on this system.  Forces B<-C>.  Forces and
1511supplies a value for B<-s>, then requires you to edit the report
1512and say what went wrong.  Alternatively, a prepared report may be
1513supplied using B<-f>.  Only prompts for a return address if it
1514cannot guess it (for use with B<make>). Honors return address
1515specified with B<-r>.  You can use this with B<-v> to get more
1516complete data.  Only makes a report if this system is less than 60
1517days old.
1518
1519=item B<-nokay>
1520
1521As B<-nok> except it will report on older systems.
1522
1523=item B<-p>
1524
1525The names of one or more patch files or other text attachments to be
1526included with the report.  Multiple files must be separated with commas.
1527
1528=item B<-r>
1529
1530Your return address.  The program will ask you to confirm its default
1531if you don't use this option.
1532
1533=item B<-S>
1534
1535Send without asking for confirmation.
1536
1537=item B<-s>
1538
1539Subject to include with the message.  You will be prompted if you don't
1540supply one on the command line.
1541
1542=item B<-t>
1543
1544Test mode.  The target address defaults to B<perlbug-test@perl.org>.
1545Also makes it possible to command perlbug from a pipe or file, for
1546testing purposes.
1547
1548=item B<-T>
1549
1550Send a thank-you note instead of a bug report.
1551
1552=item B<-v>
1553
1554Include verbose configuration data in the report.
1555
1556=back
1557
1558=head1 AUTHORS
1559
1560Kenneth Albanowski (E<lt>kjahds@kjahds.comE<gt>), subsequently
1561I<doc>tored by Gurusamy Sarathy (E<lt>gsar@activestate.comE<gt>),
1562Tom Christiansen (E<lt>tchrist@perl.comE<gt>), Nathan Torkington
1563(E<lt>gnat@frii.comE<gt>), Charles F. Randall (E<lt>cfr@pobox.comE<gt>),
1564Mike Guy (E<lt>mjtg@cam.ac.ukE<gt>), Dominic Dunlop
1565(E<lt>domo@computer.orgE<gt>), Hugo van der Sanden (E<lt>hv@crypt.orgE<gt>),
1566Jarkko Hietaniemi (E<lt>jhi@iki.fiE<gt>), Chris Nandor
1567(E<lt>pudge@pobox.comE<gt>), Jon Orwant (E<lt>orwant@media.mit.eduE<gt>,
1568Richard Foley (E<lt>richard.foley@rfi.netE<gt>), Jesse Vincent
1569(E<lt>jesse@bestpractical.comE<gt>), and Craig A. Berry (E<lt>craigberry@mac.comE<gt>).
1570
1571=head1 SEE ALSO
1572
1573perl(1), perldebug(1), perldiag(1), perlport(1), perltrap(1),
1574diff(1), patch(1), dbx(1), gdb(1)
1575
1576=head1 BUGS
1577
1578None known (guess what must have been used to report them?)
1579
1580=cut
1581
1582!NO!SUBS!
1583
1584close OUT or die "Can't close $file: $!";
1585chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
1586exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
1587chdir $origdir;
1588