Bug#758689: perldoc now outputs visible escape sequences

Niko Tyni ntyni at debian.org
Sun Aug 24 01:53:44 UTC 2014


tag  758689 confirmed patch
thanks

On Wed, Aug 20, 2014 at 06:15:55PM +1200, Olly Betts wrote:
> Package: perl
> Version: 5.20.0-4
> Severity: normal
> 
> The output from perldoc now contains visible escape sequences, e.g.:
> 
> $ perldoc perlfaq
> ESC[1mNAMEESC[0m
>     perlfaq - frequently asked questions about Perl

As discussed on IRC, this is a side effect of the default output formatter
backend changing to 'term' from 'man'. From the Pod-Perldoc changelog:

  3.20 - Sat Apr 27 05:25:30 UTC 2013
      * Make default formatter "ToTerm" instead of "ToMan" for
        better UTF-8 support

The 'man' backend doesn't have this problem, as  seen by
 $ perldoc -oman perlfaq
Also, the 'term' backend had the problem with 5.18 already, as seen with
 $ perldoc -oterm perlfaq

This seems to be a feature of the 'less' pager and doesn't happen with
for instance 'more'. Quoting less.1:

      -r or --raw-control-chars
              Causes "raw" control characters to be displayed.
              The default is to display  control  characters using  the
              caret notation; for example, a control-A (octal 001) is
              displayed as "^A".  Warning: when the -r option is used,
              less cannot keep track of the actual appearance of the
              screen (since this  depends on how the screen responds
              to each type of control character).  Thus, various dis‐
              play problems may result, such as long lines being split
              in the wrong place.

       -R or --RAW-CONTROL-CHARS
              Like -r, but only ANSI "color" escape sequences are
              output in "raw" form.  Unlike -r, the screen appearance
              is  maintained correctly in most cases. [...]


Bug #243370 is related, and Damyan has recently asked to make -R the
default. Until that, the best I can think of is to patch append the "-R"
option to $ENV{LESS} before invoking the pager. This shouldn't affect
other pagers in any way, and multiple "-R" options are ok with 'less'.
(It does seem to override "-r", but I'm not sure if we care.)

Lightly tested patch attached. I can't see a way to discover inside
Perldoc::page() whether we're using the 'ToTerm' backend, so the LESS
environment variable is changed unconditionally.
-- 
Niko Tyni   ntyni at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Tell-the-less-pager-to-allow-terminal-escape-sequenc.patch
Type: text/x-diff
Size: 1119 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/perl-maintainers/attachments/20140823/0e2a10d1/attachment.patch>


More information about the Perl-maintainers mailing list