Bug 1329059 - Don't produce terminal control sequences in perldoc
Summary: Don't produce terminal control sequences in perldoc
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Fedora
Classification: Fedora
Component: perl-Pod-Perldoc
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Petr Pisar
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 1258741
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-04-21 04:51 UTC by Pavel Raiskup
Modified: 2018-08-10 11:26 UTC (History)
7 users (show)

Fixed In Version:
Clone Of: 1258741
Environment:
Last Closed: 2016-04-21 06:28:49 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1614708 0 unspecified CLOSED perldoc warns about binary data depending on TERM variable 2021-02-22 00:41:40 UTC

Internal Links: 1614708

Description Pavel Raiskup 2016-04-21 04:51:15 UTC
+++ This bug was initially created as a clone of Bug #1258741 +++

Short summary, command 'PAGER=less perldoc perlreref' behaves oddly.

The issue is that perldoc *always* produces some terminal (color?) sequences,
and less (by default) is careful to escape terminal sequences rather then
printing them in a raw form.

This bug is here to ask whether it is possible (or makes sense) to not produce
terminal sequences in perldoc output.  Or simply request for brainstorm.

See the original bug report for more info.

Comment 1 Petr Pisar 2016-04-21 06:28:49 UTC
I cannot reproduce it on Fedora 23:

TERM=xterm
LESSOPEN=|/usr/bin/lesspipe.sh %s
ncurses-5.9-21.20150214.fc23.x86_64
ncurses-libs-5.9-21.20150214.fc23.x86_64
xterm-318-2.fc23.x86_64
less-481-1.fc23.x86_64
perl-Pod-Perldoc-3.25-347.fc23.noarch

Though I admit some people sometimes complained about the same issue. I would welcome reliable reproducer.

To the question: Yes, perldoc has "-t" argument that disables ANSI sequences on the output. I think "perldoc --help" is not so hard way to discover it.

I can fairly reproduce it with "perldoc -T perlreref | less".  The capital -T prints the output to stdout instead of sending it to a pager. But the perldoc (that I have, the behavior changes with various perldoc versions) feeds the pager from a temporary file. strace shows:

[pid  3367] execve("/usr/bin/less", ["less"], ["XDG_VTNR=1", "XDG_SESSION_ID=1", "SSH_AGENT_PID=2103", "HOSTNAME=dhcp-0-146.brq.redhat.c"..., "SHELL=/bin/bash", "TERM=xterm", "HISTSIZE=1000", "TERMPATH=/home/petr/.termcap:/et"..., "WINDOWID=65011747", "QTDIR=/usr/lib64/qt-3.3", "QTINC=/usr/lib64/qt-3.3/include", "XORG_RUN_AS_USER_OK=1", "USER=petr", "XTERM_SHELL=/bin/bash", "LS_COLORS=rs=0:di=01;34:ln=01;36"..., "SSH_AUTH_SOCK=/tmp/ssh-QUjk3MkTh"..., "PAGER=less", "PATH=/home/petr/bin:/usr/lib64/q"..., "MAIL=/var/spool/mail/petr", "_=/usr/bin/less", "QT_IM_MODULE=xim", "PWD=/home/petr", "XMODIFIERS=@im=SCIM", "EDITOR=/usr/bin/vim", "LANG=cs_CZ.UTF-8", "MODULEPATH=/etc/scl/modulefiles:"..., "LOADEDMODULES=", "HISTCONTROL=ignoredups", "XTERM_VERSION=XTerm(318)", "XTERM_LOCALE=cs_CZ.UTF-8", "HOME=/home/petr", "XDG_SEAT=seat0", "SHLVL=5", "LESS=-R", "LOGNAME=petr", "CVS_RSH=ssh", "QTLIB=/usr/lib64/qt-3.3/lib", "MODULESHOME=/usr/share/Modules", "LESSOPEN=|/usr/bin/lesspipe.sh %"..., "WINDOWPATH=1", "XDG_RUNTIME_DIR=/run/user/500", "DISPLAY=:0.0", "GTK_IM_MODULE=scim", "XAUTHORITY=/home/petr/.Xauthorit"..., "CCACHE_HASHDIR=", "BASH_FUNC_module()=() {  eval `/"..., "BASH_FUNC_scl()=() {  local CMD="...]) = 0

I suspect perldoc sets LESS=-R. I dont' have the variable in my environment:

$ set |grep LESS
LESSOPEN='|/usr/bin/lesspipe.sh %s'

"perldoc -T perlreref | LESS=-R less" works for me.

From my point of view, perldoc is fine in Fedora. This is issue in RHEL-7's perldoc.

Comment 2 Petr Pisar 2016-04-21 06:43:29 UTC
Actually I cannot reproduce it in RHEL-7 either. Thought it works there probably for some other reason. If you want to open a bug for RHEL-7, I need the reproducer.

Comment 3 Pavel Raiskup 2016-04-21 07:01:07 UTC
(In reply to Petr Pisar from comment #1)
> I cannot reproduce it on Fedora 23:

I feel I'm facing some magic, because I'm not able to reproduce this on F23
neither, *now*.

> To the question: Yes, perldoc has "-t" argument that disables ANSI sequences
> on the output. I think "perldoc --help" is not so hard way to discover it.

The question is whether it would be possible to not print terminal sequences
*by default*;  not how it can be done.  But yes -- as it obviously works on
F23, there is no need to change anything.
 
> I suspect perldoc sets LESS=-R. I dont' have the variable in my environment:

That's right.
 
> From my point of view, perldoc is fine in Fedora. This is issue in RHEL-7's
> perldoc.

Correct.

(In reply to Petr Pisar from comment #2)
> Actually I cannot reproduce it in RHEL-7 either. Thought it works there
> probably for some other reason. If you want to open a bug for RHEL-7, I need
> the reproducer.

In RHEL7, I'm able to reproduce it.  Perldoc does not set the LESS variable,
can be debugged by:

  $ cat lesswrap
  #! /bin/sh
  env | grep -i less
  less "$@"

  $ PAGER=./lesswrap perldoc perlreref

Petr, can you confirm?

Comment 4 Pavel Raiskup 2016-04-21 07:04:58 UTC
(In reply to Pavel Raiskup from comment #3)
> In RHEL7, I'm able to reproduce it.  Perldoc does not set the LESS variable,
> can be debugged by:
> 
>   $ cat lesswrap
>   #! /bin/sh
>   env | grep -i less
>   less "$@"
> 
>   $ PAGER=./lesswrap perldoc perlreref
> 
> Petr, can you confirm?

While, of course, you can use:

  $ PERLDOCDEBUG=1 PAGER=./lesswrap perldoc perlreref
  $ # hit the CTRL^Z
  $ # open the temp file generated by perldoc to see that the color sequences
    # are there.

Comment 5 Petr Pisar 2016-04-21 07:13:10 UTC
Yes, in RHEL-7 if the PAGER is defined, then the ANSI sequences are not interpreted.


Note You need to log in before you can comment on or make changes to this bug.