Hi Andrew,

Andrew Daugherity wrote on Thu, May 02, 2019 at 10:53:37AM -0500:

> Also, their ToMan patch has a previously-included hunk
> for MANWIDTH=tty,

All that does is suppress a warning message "non-numeric MANWIDTH"
when a user has MANWIDTH=tty in their environment.  No idea why any
user would have that.  I see no reason to merge that part of the
patch to OpenBSD.

> but it doesn't seem to do anything for me?)

No, it doesn't do anything on OpenBSD because _get_columns() never
gets called when mandoc(1) is being used.

Then again, there is no real reason why _get_columns() isn't used
with mandoc: mandoc does support setting the output width.
Not via "-rLL=" though, that is a groffism.

If people want perldoc(1) to respect the MANWIDTH environment
variable, we could commit the following patch (and feed it upstream).

I don't really care either way.

Regarding the patch below, note that i'm deliberately not doing any
validation or truncation.  People who trust environment variables
enough to use them but not enough to use them without validation
seem silly to me.  On the one hand, the existing code in ToMan.pm
already does validation on MANWIDTH which does not need to be
repeated.  On the other hand, even if it wouldn't, why not leave
the validation to mandoc(1), which already validates the -O width=
argument?

In mandoc(1)/man(1) itself, i decided against supporting the MANWIDTH
variable.  In general, i hate environment variables.  They stealthily
change the behaviour of programs, making debugging harder and causing
needless headaches about security boundaries when leaking from one
process into its children.  In man(1) and mandoc(1), supporting
MANWIDTH would be pointless because you can already use the -O width=
option if you want to, which is clearer and less sneaky.

Yours,
  Ingo


Index: 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
--- ToMan.pm    13 Feb 2019 21:15:14 -0000      1.8
+++ ToMan.pm    3 May 2019 02:49:03 -0000
@@ -227,6 +227,10 @@ sub _collect_nroff_switches {
                push @render_switches, '-rLL=' . (int $c) . 'n' if $cols > 80;
                }
 
+       if( $self->_is_mandoc ) {
+               push @render_switches, '-Owidth=' . $self->_get_columns;
+               }
+
        # I hear persistent reports that adding a -c switch to $render
        # solves many people's problems.  But I also hear that some mans
        # don't have a -c switch, so that unconditionally adding it here

Reply via email to