Subject: | pod2man: no exit code & empty files left behind |
pod2man always exit with status 0 even if conversion failed.
Worse, empty files left behind, for example if invoked like
pod2man /dev/null null.1 && echo OK
"OK" will be printed and empty file "null.1" will be created.
Empty file left by Pod::Simple because it create output file before
content generation. If no content produced, empty file left behind.
On top of this pod2man exit with status code 0 disregarding
conversion result.
The attached patch addresses both problems. (Sorry for not making test
case for this)
Regards,
Dmitry.
P.S. corresponding Debian bug number is #659939, see
http://bugs.debian.org/659939
Subject: | pod2man_exit-status.patch |
Author: Dmitry Smirnov <onlyjob@member.fsf.org>
Last-Update: 2012-02-18
Forwarded: yes
Bug-Debian: http://bugs.debian.org/659939
Description: return code & empty files cleanup for pod2man
pod2man leaves empty file if no POD content in input file.
This is because Pod::Simple create file before generating
output. If there is no content, empty file left behind.
.
On top of this pod2man always exit with status code 0 disregarding
conversion result. This patch addresses both problems.
--- a/cpan/podlators/scripts/pod2man.PL
+++ b/cpan/podlators/scripts/pod2man.PL
@@ -83,13 +83,21 @@
# Initialize and run the formatter, pulling a pair of input and output off at
# a time.
my $parser = Pod::Man->new (%options);
+my $exit_status=0;
my @files;
do {
@files = splice (@ARGV, 0, 2);
print " $files[1]\n" if $verbose;
- $parser->parse_from_file (@files);
+ my $pff_ref=$parser->parse_from_file (@files);
+ if($pff_ref->{'CONTENTLESS'}){ # no output content
+ $exit_status+=1;
+ unlink $files[1] unless -s $files[1]; # remove empty destination
+ # file if no output produced
+ }
} while (@ARGV);
+exit $exit_status;
+
__END__
=head1 NAME