avoid literal 'undef' in $lddlflags under `Configure -Uoptimize`
[p5sagit/p5-mst-13.2.git] / utils / perlbug.PL
index 1a39bdb..377893a 100644 (file)
@@ -86,7 +86,7 @@ BEGIN {
     $::HaveUtil = ($@ eq "");
 };
 
-my $Version = "1.24";
+my $Version = "1.26";
 
 # Changed in 1.06 to skip Mail::Send and Mail::Util if not available.
 # Changed in 1.07 to see more sendmail execs, and added pipe output.
@@ -115,6 +115,8 @@ my $Version = "1.24";
 # Changed in 1.22 Heavy reformatting & minor bugfixes HVDS 98-05-10
 # Changed in 1.23 Restore -ok(ay): say 'success'; don't prompt
 # Changed in 1.24 Added '-F<file>' to save report HVDS 98-07-01
+# Changed in 1.25 Warn on failure to open save file. HVDS 98-07-12
+# Changed in 1.26 Don't require -t STDIN for -ok. HVDS 98-07-15
 
 # TODO: - Allow the user to re-name the file on mail failure, and
 #       make sure failure (transmission-wise) of Mail::Send is
@@ -131,7 +133,7 @@ Init();
 
 if ($::opt_h) { Help(); exit; }
 if ($::opt_d) { Dump(*STDOUT); exit; }
-if (!-t STDIN) {
+if (!-t STDIN && !($ok and not $::opt_n)) {
     paraprint <<EOF;
 Please use perlbug interactively. If you want to
 include a file, you can use the -f switch.
@@ -153,7 +155,7 @@ sub Init {
     $Is_MSWin32 = $^O eq 'MSWin32';
     $Is_VMS = $^O eq 'VMS';
 
-    getopts("dhva:s:b:f:F:r:e:SCc:to:n:");
+    if (!getopts("dhva:s:b:f:F:r:e:SCc:to:n:")) { Help(); exit; };
 
     # This comment is needed to notify metaconfig that we are
     # using the $perladmin, $cf_by, and $cf_time definitions.
@@ -493,8 +495,8 @@ sub Dump {
     local(*OUT) = @_;
 
     print REP "\n---\n";
-    print REP "This perlbug was built using Perl $config_tag1\n",
-           "It is being executed now by  Perl $config_tag2.\n\n"
+    print REP "This perlbug was built using Perl $config_tag2\n",
+           "It is being executed now by  Perl $config_tag1.\n\n"
        if $config_tag2 ne $config_tag1;
 
     print OUT <<EOF;
@@ -526,7 +528,7 @@ EOF
 Environment for perl $]:
 EOF
     for my $env (sort
-       (qw(PATH LD_LIBRARY_PATH LANG PERL_BADLANG SHELL HOME LOGDIR),
+       (qw(PATH LD_LIBRARY_PATH LANG PERL_BADLANG SHELL HOME LOGDIR LANGUAGE),
        grep /^(?:PERL|LC_)/, keys %ENV)
     ) {
        print OUT "    $env",
@@ -623,6 +625,7 @@ the message to $address$andcc, display the message on
 the screen, re-edit it, 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): ";
            my $action = scalar <>;
            chop $action;
@@ -633,7 +636,10 @@ EOF
                chop $file;
                $file = "perlbug.rep" if $file eq "";
 
-               open(FILE, ">$file");
+               unless (open(FILE, ">$file")) {
+                   print "\nError opening $file: $!\n\n";
+                   goto retry;
+               }
                open(REP, "<$filename");
                print FILE "To: $address\nSubject: $subject\n";
                print FILE "Cc: $cc\n" if $cc;
@@ -895,6 +901,13 @@ it all, but at least have a look at the sections that I<seem> relevant).
 Be aware of the familiar traps that perl programmers of various hues
 fall into.  See L<perltrap>.
 
+Check in L<perldiag> to see what any Perl error message(s) mean.
+If message isn't in perldiag, it probably isn't generated by Perl.
+Consult your operating system documentation instead.
+
+If you are on a non-UNIX platform check also L<perlport>, some
+features may not be implemented or work differently.
+
 Try to study the problem under the perl debugger, if necessary.
 See L<perldebug>.
 
@@ -910,6 +923,17 @@ A good test case is almost always a good candidate to be on the perl
 test suite.  If you have the time, consider making your test case so
 that it will readily fit into the standard test suite.
 
+Remember also to include the B<exact> error messages, if any.
+"Perl complained something" is not an exact error message.
+
+If you get a core dump (or equivalent), you may use a debugger
+(B<dbx>, B<gdb>, etc) to produce a stack trace to include in the bug
+report.  NOTE: unless your Perl has been compiled with debug info
+(often B<-g>), the stack trace is likely to be somewhat hard to use
+because it will most probably contain only the function names, not
+their arguments.  If possible, recompile your Perl with debug info and
+reproduce the dump and the stack trace.
+
 =item Can you describe the bug in plain English?
 
 The easier it is to understand a reproducible bug, the more likely it
@@ -948,6 +972,11 @@ it to B<perlbug@perl.com>.  If, for some reason, you cannot run
 C<perlbug> at all on your system, be sure to include the entire output
 produced by running C<perl -V> (note the uppercase V).
 
+Whether you use C<perlbug> or send the email manually, please make
+your subject informative.  "a bug" not informative.  Neither is "perl
+crashes" nor "HELP!!!", these all are null information.  A compact
+description of what's wrong is fine.
+
 =back
 
 Having done your bit, please be prepared to wait, to be told the bug
@@ -1065,12 +1094,14 @@ Kenneth Albanowski (E<lt>kjahds@kjahds.comE<gt>), subsequently I<doc>tored
 by Gurusamy Sarathy (E<lt>gsar@umich.eduE<gt>), Tom Christiansen
 (E<lt>tchrist@perl.comE<gt>), Nathan Torkington (E<lt>gnat@frii.comE<gt>),
 Charles F. Randall (E<lt>cfr@pobox.comE<gt>), Mike Guy
-(E<lt>mjtg@cam.a.ukE<gt>), Dominic Dunlop (E<lt>domo@computer.orgE<gt>)
-and Hugo van der Sanden (E<lt>hv@crypt0.demon.co.ukE<gt>).
+(E<lt>mjtg@cam.a.ukE<gt>), Dominic Dunlop (E<lt>domo@computer.orgE<gt>),
+Hugo van der Sanden (E<lt>hv@crypt0.demon.co.ukE<gt>), and
+Jarkko Hietaniemi (E<lt>jhi@iki.fiE<gt>).
 
 =head1 SEE ALSO
 
-perl(1), perldebug(1), perltrap(1), diff(1), patch(1)
+perl(1), perldebug(1), perldiag(1), perlport(1), perltrap(1),
+diff(1), patch(1), dbx(1), gdb(1)
 
 =head1 BUGS
 
@@ -1084,4 +1115,3 @@ close OUT or die "Can't close $file: $!";
 chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
 exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
 chdir $origdir;
-