Bug#758689: perldoc now outputs visible escape sequences

2014-08-23 Thread Niko Tyni
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   nt...@debian.org
From 314cc25bca7ab3d6a3b2e040bbb496c47419bb87 Mon Sep 17 00:00:00 2001
From: Niko Tyni nt...@debian.org
Date: Sat, 23 Aug 2014 18:46:43 -0700
Subject: [PATCH] Tell the 'less' pager to allow terminal escape sequences

The 'ToTerm' backend generates terminal escape sequences that
the 'less' pager does not display by default. The -R option
controls this, so pass it in the LESS environment variable
to avoid disturbing other pager invocations.

Bug-Debian: https://bugs.debian.org/758689
---
 cpan/Pod-Perldoc/lib/Pod/Perldoc.pm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cpan/Pod-Perldoc/lib/Pod/Perldoc.pm b/cpan/Pod-Perldoc/lib/Pod/Perldoc.pm
index 6ddd21d..5c6ea98 100644
--- a/cpan/Pod-Perldoc/lib/Pod/Perldoc.pm
+++ b/cpan/Pod-Perldoc/lib/Pod/Perldoc.pm
@@ -1892,6 +1892,7 @@ sub page {  # apply a pager to the output file
 if ($self-is_vms) {
 last if system($pager $output) == 0;
 } else {
+$ENV{LESS} .=  -R; # ToTerm outputs escape codes
 last if system($pager \$output\) == 0;
 }
 }
-- 
2.1.0



Bug#758689: perldoc now outputs visible escape sequences

2014-08-20 Thread Olly Betts
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

ESC[1mDESCRIPTIONESC[0m
The perlfaq comprises several documents that answer the most commonly
asked questions about Perl and Perl programming. It's divided by topic
into nine major sections outlined in this document.

(With the ESC in reverse video).

If I pipe output through more, it looks correct, e.g.:
$ perldoc perlfaq|more
NAME
perlfaq - frequently asked questions about Perl

DESCRIPTION
The perlfaq comprises several documents that answer the most commonly
asked questions about Perl and Perl programming. It's divided by topic
into nine major sections outlined in this document.

(with NAME and DESCRIPTION in bold).

I think this start to happen after I upgraded to perl 5.20 - it
certainly didn't happen last time I used perldoc.

Cheers,
Olly

-- System Information:
Debian Release: jessie/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.14-2-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_NZ.UTF-8, LC_CTYPE=en_NZ.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages perl depends on:
ii  libbz2-1.01.0.6-7
ii  libc6 2.19-9
ii  libdb5.3  5.3.28-5
ii  libgdbm3  1.8.3-13
ii  perl-base 5.20.0-4
ii  perl-modules  5.20.0-4
ii  zlib1g1:1.2.8.dfsg-2

Versions of packages perl recommends:
ii  netbase  5.2
ii  rename   0.20-3

Versions of packages perl suggests:
pn  libterm-readline-gnu-perl | libterm-readline-perl-perl  none
ii  make4.0-8
ii  perl-doc5.20.0-4

-- no debconf information


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org