## 2019 06 01.01
+ - fixed issue RT#130297; the perltidy script now exits with a nonzero exit
+ status if it wrote to the standard error output. Prevously only fatal
+ run errors produced a non-zero exit flag. Now, even non-fatal messages
+ requested with the -w flag will cause a non-zero exit flag. The exit
+ flag now has these values:
+
+ 0 = no errors
+ 1 = fatal error
+ 2 = non-fatal error
+
- added warning message for RT#130008, which warns of conflicting input
parameters -iob and -bom or -boc.
);
}
-Perl::Tidy::perltidy( argv => $arg_string );
+# Exit codes returned by perltidy:
+# 0 - successful run without errors
+# 1 - run terminated with a fatal error
+# 2 - successful run but with non-fatal warning messages
+exit Perl::Tidy::perltidy( argv => $arg_string );
__END__
$missing_file_spec
$fh_stderr
$rOpts_character_encoding
+ $Warn_count
};
@ISA = qw( Exporter );
$fh_stderr = *STDERR;
}
- sub Warn { my $msg = shift; $fh_stderr->print($msg); return }
+ sub Warn { my $msg = shift; $fh_stderr->print($msg); $Warn_count++; return }
sub Exit {
my $flag = shift;
if $logger_object;
} # end of main loop to process all files
+ # Fix for RT #130297: return a true value if anything was written to the
+ # standard error output, even non-fatal warning messages, otherwise return
+ # false.
+
+ # To allow the caller to determine the error severity, these exit codes are
+ # returned:
+ # 0 - successful run without errors
+ # 1 - run terminated with a fatal error
+ # 2 - successful run but with non-fatal warning messages
+
+ # Note that if perltidy is run with multiple files, any single file with
+ # errors or warnings will write a line like
+ # '## Please see file testing.t.ERR'
+ # to standard output for each file with errors, so the flag will be true,
+ # even only some of the multiple files may have had errors.
+
NORMAL_EXIT:
- return 0;
+ my $ret = $Warn_count ? 2 : 0;
+ return $ret;
ERROR_EXIT:
return 1;