[Bug 1734702] Re: perldoc shows lots of escapes
Eliah Kagan
degeneracypressure at gmail.com
Mon Jan 8 12:03:35 UTC 2018
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 this may be preferred, because if you have a LESS environment
variable with other options, they will still be used (and if not, it has
the same effect as above):
LESS="$LESS -R" perldoc perlsyn
Or you can pipe to less and pass -R:
perldoc perlsyn | less -R
If these workarounds do not work for you (i.e., for the original author
of this bug report), then I might be mistaken in my belief that the bug
I am experiencing is the same as yours.
This bug does not appear to affect Ubuntu 16.04 LTS. It does not happen
on my Lubuntu 16.04 LTS (64-bit) system. Ubuntu 16.04 LTS has
"/usr/share/perl/5.22/Pod/Perldoc.pm" which uses this loop to open the
document in a pager:
foreach my $pager (@pagers) {
$self->aside("About to try calling $pager $output\n");
if ($self->is_vms) {
last if system("$pager $output") == 0;
} else {
# fix visible escape codes in ToTerm output
# bugs.debian.org/758689
local $ENV{LESS} = defined $ENV{LESS} ? "$ENV{LESS} -R" : "-R";
last if system("$pager \"$output\"") == 0;
}
}
Ubuntu 17.10 has this corresponding loop, which no longer directly
attempts to modify the LESS environment variable in order to prevent
Debian Bug 758689 from occurring:
foreach my $pager (@pagers) {
$self->aside("About to try calling $pager $output\n");
if ($self->is_vms) {
last if system("$pager $output") == 0;
} elsif($self->is_amigaos) {
last if system($pager, $output) == 0;
} else {
my $formatter = $self->{'formatter_class'};
if ( $formatter->can('pager_configuration') ) {
$self->aside("About to call $formatter" . "->pager_configuration(\"$pager\")\n");
$formatter->pager_configuration($pager, $self);
}
last if system("$pager \"$output\"") == 0;
}
}
** Bug watch added: Debian Bug tracker #735134
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=735134
** Bug watch added: Debian Bug tracker #758689
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=758689
** Attachment added: "Text displayed in the terminal when I ran "perldoc -D perlsyn""
https://bugs.launchpad.net/ubuntu/+source/perl/+bug/1734702/+attachment/5032746/+files/perldoc_-D_perlsyn.txt
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to perl in Ubuntu.
https://bugs.launchpad.net/bugs/1734702
Title:
perldoc shows lots of escapes
Status in perl package in Ubuntu:
Confirmed
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)
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/perl/+bug/1734702/+subscriptions
More information about the foundations-bugs
mailing list