On Fri, May 03, 2019 at 04:27:15AM +0200, Ingo Schwarze wrote:
> Hi Todd & Andrew,
> 
> Andrew Fresh wrote on Thu, May 02, 2019 at 09:53:29AM -0700:
> > On Thu, May 02, 2019 at 10:21:15AM -0600, Todd C. Miller wrote:
> >> On Thu, 02 May 2019 10:53:37 -0500, Andrew Daugherity wrote:
> 
> >>> I reported this to FreeBSD ports a couple months ago [2], and they
> >>> provided a fix [3] which repairs the -oMan output, and makes that the
> >>> default.  Their fix applies cleanly to the OpenBSD tree and works, but
> >>> I have no idea why mandoc requires resetting $?.  (Also, their ToMan
> >>> patch has a previously-included hunk for MANWIDTH=tty, but it doesn't
> >>> seem to do anything for me?)
> 
> >> There problem is a missing waitpid() call, so $? is not actually
> >> set.  Something like the following should be better, though I haven't
> >> tested it yet.
> 
> > This seems to work fine for me, OK afresh1@
> 
> OK schwarze@, too.
> 
> > I submitted this upstream as well, so hopefully shouldn't have to keep
> > the patch for too long.
> > https://github.com/mrallen1/Pod-Perldoc/pull/39
> 
> Thanks.
> 
> > Still looking at defaulting to -oMan, but probably a good idea.
> 
> I agree in principle that -oMan ought to become the default.


There is an upstream patch to do this if the "nroffer" is a new-enough
groff or an older groff with the pager less.  I added a comment
recommending that the should also set the pager to "man" if the
"nroffer" is mandoc, which is the default on the BSD's it recognizes.
I'm not sure if I can add a patch directly to a GitHub PR that I didn't
create, but I may still make one and attach it somehow.


In any case, I'll probably commit this slightly cleaned up version
tomorrow as it's to late right now to make sure I didn't clean it too
far.

 
Index: gnu/usr.bin/perl/cpan/Pod-Perldoc/lib/Pod/Perldoc.pm
===================================================================
RCS file: /cvs/src/gnu/usr.bin/perl/cpan/Pod-Perldoc/lib/Pod/Perldoc.pm,v
retrieving revision 1.4
diff -u -p -r1.4 Perldoc.pm
--- gnu/usr.bin/perl/cpan/Pod-Perldoc/lib/Pod/Perldoc.pm        13 Feb 2019 
21:15:14 -0000      1.4
+++ gnu/usr.bin/perl/cpan/Pod-Perldoc/lib/Pod/Perldoc.pm        3 May 2019 
04:29:51 -0000
@@ -486,6 +486,8 @@ sub init_formatter_class_list {
 
   $self->opt_M_with('Pod::Perldoc::ToPod');   # the always-there fallthru
   $self->opt_o_with('text');
+  $self->opt_o_with('man')
+    if $ENV{TERM} && $ENV{TERM} !~ /dumb|emacs|none|unknown/i;
 
   return;
 }
Index: gnu/usr.bin/perl/cpan/Pod-Perldoc/lib/Pod/Perldoc/ToMan.pm
===================================================================
RCS file: /cvs/src/gnu/usr.bin/perl/cpan/Pod-Perldoc/lib/Pod/Perldoc/ToMan.pm,v
retrieving revision 1.8
diff -u -p -r1.8 ToMan.pm
--- gnu/usr.bin/perl/cpan/Pod-Perldoc/lib/Pod/Perldoc/ToMan.pm  13 Feb 2019 
21:15:14 -0000      1.8
+++ gnu/usr.bin/perl/cpan/Pod-Perldoc/lib/Pod/Perldoc/ToMan.pm  3 May 2019 
04:29:51 -0000
@@ -352,6 +352,9 @@ sub _filter_through_nroff {
        close $writer;
        $self->debug( "Done writing\n" );
 
+       # wait for it to exit
+       waitpid( $pid, 0 );
+
        # read any leftovers
        $done .= do { local $/; <$reader> };
        $self->debug( sprintf "Done reading. Output is %d bytes\n",

Reply via email to