]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix git #49, -se breaks warning exit status behavior
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 8 Dec 2020 15:04:59 +0000 (07:04 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 8 Dec 2020 15:04:59 +0000 (07:04 -0800)
lib/Perl/Tidy.pm
lib/Perl/Tidy/Logger.pm
local-docs/BugLog.pod

index bcf82a7345e8a789c2d3d125ba3fc549a1584833..826337668a3ca57132bb778e98e01a57a053c6ff 100644 (file)
@@ -383,6 +383,15 @@ sub find_input_line_ending {
 
 my $Warn_count;
 my $fh_stderr;
+
+# Bump Warn_count only: it is essential to bump the count on all warnings, even
+# if no message goes out, so that the correct exit status is set.
+sub Warn_count_bump { $Warn_count++; return }
+
+# Output Warn message only
+sub Warn_msg { my $msg = shift; $fh_stderr->print($msg); return }
+
+# Output Warn message and bump Warn count
 sub Warn { my $msg = shift; $fh_stderr->print($msg); $Warn_count++; return }
 
 sub perltidy {
@@ -1572,7 +1581,7 @@ EOM
                     $logger_object->interrupt_logfile();
                     $logger_object->warning( $diff_msg . "\n" );
                     $logger_object->resume_logfile();
-                    $Warn_count ||= 1;   # insure correct exit if -q flag is set
+                    ## $Warn_count ||= 1;   # logger warning does this now
                 }
             }
             if ( $rOpts->{'assert-untidy'} ) {
@@ -1581,7 +1590,7 @@ EOM
                     $logger_object->warning(
 "assertion failure: '--assert-untidy' is set but output equals input\n"
                     );
-                    $Warn_count ||= 1;   # insure correct exit if -q flag is set
+                    ## $Warn_count ||= 1;   # logger warning does this now
                 }
             }
 
index d6ef73695975fac897f068757bc7a6d9ef8599ac..9d2cce88415859fb557b964c9101032a83a1a470 100644 (file)
@@ -351,6 +351,9 @@ sub warning {
     #use constant WARNING_LIMIT => 50;
     my $WARNING_LIMIT = 50;
 
+    # Always bump the warn count, even if no message goes out
+    Perl::Tidy::Warn_count_bump();
+
     my $rOpts = $self->{_rOpts};
     unless ( $rOpts->{'quiet'} ) {
 
@@ -362,7 +365,7 @@ sub warning {
             ( $fh_warnings, my $filename ) =
               Perl::Tidy::streamhandle( $warning_file, 'w', $is_encoded_data );
             $fh_warnings or Perl::Tidy::Die("couldn't open $filename $!\n");
-            Perl::Tidy::Warn("## Please see file $filename\n")
+            Perl::Tidy::Warn_msg("## Please see file $filename\n")
               unless ref($warning_file);
             $self->{_fh_warnings} = $fh_warnings;
             $fh_warnings->print("Perltidy version is $Perl::Tidy::VERSION\n");
index a7df26489e13ec4c9a238cdefbed09a04d3dac04..2a9e62b26046ebaa5a046a0d100de67306004a30 100644 (file)
@@ -1,3 +1,15 @@
+=head1 Issues fixed after release 20201207
+
+=over 4
+
+=item B<Fix for issue git #49, exit status not correctly set>
+
+The exit status flag was not being set for the -w option if the -se or if the -q flag
+were set.  Issue git #44 was similar but a special case of the problem.  The 
+problem was fixed 8 Dec 2020.
+
+=back
+
 =head1 Issues fixed after release 20201202
 
 =over 4