Subject: | [PATCH] Don't use perldoc if is is missing |
I have a CPAN distribution (Filter-Crypto) containing a script with a
"-m" option for printing out its manpage using pod2usage(-exitval => 1,
-verbose => 2). Generally the test passes, but one or two CPAN Testers
keep getting failures, with no output generated instead of the expected
manpage.
I have added some diag()nostics to the failing test to see if perldoc is
present or not, and I've found that it is missing on all systems where
the test fails. You can see a typical failure report here:
http://www.cpantesters.org/cpan/report/cb88d8ce-6705-11e1-b06a-e122c37f204a
(Note that the scriptdir and scriptdirexp locations are both the same,
so even the recent fix for CPAN#57954 won't fix it.)
I have no idea why these systems have no perldoc on them (despite, as
the list of prerequisites in the CPAN Testers reports show, having
Pod::Usage installed), but I propose the attached patch to Pod::Usage as
a solution.
It tests to see if perldoc exists and sets the '-noperldoc' option if it
does not, causing the manpage to be printed by the other means on those
systems with no perldoc.
Subject: | perldoc.patch |
diff -ruN Pod-Parser-1.51.orig\lib\Pod\Usage.pm Pod-Parser-1.51\lib\Pod\Usage.pm
--- Pod-Parser-1.51.orig\lib\Pod\Usage.pm Wed Jan 25 06:19:04 2012
+++ Pod-Parser-1.51\lib\Pod\Usage.pm Wed Mar 07 08:44:15 2012
@@ -567,6 +567,11 @@
$opts{'-verbose'} = 1;
}
+ ## Check for perldoc
+ my $progpath = File::Spec->catfile($Config{scriptdirexp}
+ || $Config{scriptdir}, 'perldoc');
+ $opts{'-noperldoc'} = 1 unless -e $progpath;
+
## Now translate the pod document and then exit with the desired status
if ( !$opts{'-noperldoc'}
and $opts{'-verbose'} >= 2
@@ -574,8 +579,6 @@
and $opts{'-output'} == \*STDOUT )
{
## spit out the entire PODs. Might as well invoke perldoc
- my $progpath = File::Spec->catfile($Config{scriptdirexp}
- || $Config{scriptdir}, 'perldoc');
print { $opts{'-output'} } ($opts{'-message'}, "\n") if($opts{'-message'});
if(defined $opts{-input} && $opts{-input} =~ /^\s*(\S.*?)\s*$/) {
# the perldocs back to 5.005 should all have -F