From: Steve Hancock Date: Tue, 8 Dec 2020 15:04:59 +0000 (-0800) Subject: fix git #49, -se breaks warning exit status behavior X-Git-Tag: 20210111~48 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=cb60285771c0490fc2b12d1977b39ae81436d16f;p=perltidy.git fix git #49, -se breaks warning exit status behavior --- diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index bcf82a73..82633766 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -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 } } diff --git a/lib/Perl/Tidy/Logger.pm b/lib/Perl/Tidy/Logger.pm index d6ef7369..9d2cce88 100644 --- a/lib/Perl/Tidy/Logger.pm +++ b/lib/Perl/Tidy/Logger.pm @@ -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"); diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index a7df2648..2a9e62b2 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -1,3 +1,15 @@ +=head1 Issues fixed after release 20201207 + +=over 4 + +=item B + +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