perldoc shows lots of escapes

Bug #1734702 reported by janl
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
perl (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Fresh konsole:
$ echo $TERM
xterm-256color
$ type perldoc
perldoc is /usr/bin/perldoc
$ dpkg -S /usr/bin/perldoc
diversion by perl-doc from: /usr/bin/perldoc
diversion by perl-doc to: /usr/bin/perldoc.stub
perl, perl-doc: /usr/bin/perldoc
$ echo $PAGER

$ perldoc perlsyn

(Now in pager:)

ESC[1mNAMEESC[0m
    perlsyn - Perl syntax

ESC[1mDESCRIPTIONESC[0m
    A Perl program consists of a sequence of declarations and statements which
...

That's a lot of ESCapes. PAGER=more gets me "2NAME2" and the like.

$ locate perlsyn
/usr/share/man/man1/perlsyn.1.gz
/usr/share/man/man1/perlsynology.1.gz
/usr/share/perl/5.26.0/pod/perlsyn.pod
/usr/share/perl/5.26.0/pod/perlsynology.pod

No cached files apparently.

This works reasonably: TERM=none perldoc perlsyn | (TERM=vt100 less) - but looses the bolds etc.

This works well: man perlsyn

This also works as expected, showing bolds and stuff, but I find it impractical:
    perldoc perlsyn | cat

So perldoc applies terminal appropriate escapes where it should not?

ProblemType: Bug
DistroRelease: Ubuntu 17.10
Package: perl-doc 5.26.0-8ubuntu1
ProcVersionSignature: Ubuntu 4.13.0-17.20-generic 4.13.8
Uname: Linux 4.13.0-17-generic x86_64
ApportVersion: 2.20.7-0ubuntu3.5
Architecture: amd64
CurrentDesktop: KDE
Date: Mon Nov 27 15:23:57 2017
EcryptfsInUse: Yes
InstallationDate: Installed on 2017-07-18 (132 days ago)
InstallationMedia: Kubuntu 17.04 "Zesty Zapus" - Release amd64 (20170412)
PackageArchitecture: all
SourcePackage: perl
UpgradeStatus: Upgraded to artful on 2017-11-27 (0 days ago)

Revision history for this message
janl (janl) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in perl (Ubuntu):
status: New → Confirmed
Revision history for this message
Eliah Kagan (degeneracypressure) wrote :
Download full text (5.0 KiB)

This bug affects my Lubuntu 17.10 (64-bit) system, which has version 5.26.0-8ubuntu1 of the perl and perl-doc packages. I noticed the bug immediately upon checking for it after Zanna (https://launchpad.net/~rose-anna-bleasdale / https://askubuntu.com/users/527764/zanna) reported experiencing it in Ubuntu MATE 17.10. Until this bug is fixed, I suggest the workaround of setting the PAGER environment variable to "less" so that the proper configuration for less is used; other full workarounds are also effective (see below).

The problem does not appear to depend in any way on what sort of terminal emulator is used. I tried in LXTerminal (TERM=xterm), XTerm (TERM=xterm), a virtual console (TERM=linux), and via SSH (TERM=xterm). Zanna tried in MATE Terminal (TERM=xterm), GNOME Terminal (TERM=xterm-256color), Konsole (TERM=xterm-256color), Tilda (TERM=xterm-256color), XTerm (TERM=xterm), and a virtual console (TERM=linux). See https://chat.stackexchange.com/transcript/message/42130009#42130009 and subsequent messages for details. It occurred for us both no matter what terminals we used. I believe this is the same bug as reported here.

In case it is helpful, I have attached a file showing the debugging output produced by running "perldoc -D perlsyn" on my Lubuntu 17.10 system. Note the presence of this line:

    About to call Pod::Perldoc::ToTerm->pager_configuration("/usr/bin/sensible-pager")

I suspect that the problem is that the necessary configuration for less to permit terminal escape sequences--specifically, that the -R option either be passed to it or present in the LESS environment variable--is not satisfied when the pager configuration for sensible-pager is used, even when sensible-pager runs less, as it does by default in Ubuntu.

I further suspect that many, or perhaps all, 17.10 systems have this bug in their default configuration (though it would only be noticed if users install and run perldoc). This strongly resembles https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=735134. This bug may be considered a regression, in that the problem had previously occurred and was then prevented by the addition of this code in Perldoc.pm, which is present in 16.04 but removed in 17.10 (see below for details):

    # fix visible escape codes in ToTerm output
    # https://bugs.debian.org/758689
    local $ENV{LESS} = defined $ENV{LESS} ? "$ENV{LESS} -R" : "-R";

The simplest workaround for this bug that I am aware of is to pass the -t flag to perldoc. As in the workaround described in the bug report here, the resulting formatting is readable but not as fancy as usual.

A *full* workaround is also possible, and is only slightly more complicated. Telling perldoc explicitly that you want "less" by defining the PAGER environment variable works:

    PAGER=less perldoc perlsyn

Otherwise, it finds sensible-pager first (see above), and appears not to place -R in LESS (see below), because it does not know that the sensible-pager shell script runs less.

The problem may also be avoided by ensuring that an environment variable with the name LESS and a value that specifies the R option is present. For example, this works:

    LESS=-R perldoc perlsyn

Or thi...

Read more...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.