adjust searchdict.t for EBCDIC (still needs documenting)
[p5sagit/p5-mst-13.2.git] / utils / perlbug.PL
index 1a39bdb..589e7e6 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.
@@ -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;