Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters

[perl #72156] perldoc should ask less to handle ANSI escapes

 

 

Perl porters RSS feed   Index | Next | Previous | View Threaded


perlbug-followup at perl

Jan 17, 2010, 6:21 PM

Post #1 of 6 (341 views)
Permalink
[perl #72156] perldoc should ask less to handle ANSI escapes

# New Ticket Created by Joshua b. Jore
# Please include the string: [perl #72156]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=72156 >


This is a bug report for perl from jbenjore [at] w3m211a,
generated with the help of perlbug 1.39 running under perl 5.11.3.


-----------------------------------------------------------------
[Please describe your issue here]

It's apparently becoming common for pod2man's output to use ANSI
escape codes for highlighting instead of overstrike using
backspaces. Historically the section names like NAME are highlighted
by outputting "N\bNA\bAM\bME\bE" so a line printer would
overstrike. groff from MacPorts and mandriva Linux and I suppose more
places is now printing "\e[.1mNAME\e[.0m" as ANSI escapes.

Seemingly all versions of less will just display the escape codes
"ESC[.1mNAMEESC[.0m" with the "ESC" part highlighted because it's a
control character.

less versions less than 419 checked the first 64 characters which
worked out just fine:

'strict(3) User Contributed Perl Documentation '

less version version 419+ check the first 256 bytes for "binary" and
thinks the escape character is binary.

In general, just ask less to interpret the escape codes:

-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 display
prob- lems 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. ANSI "color"
escape sequences are sequences of the form:

ESC [. ... m

where the "..." is zero or more color specification
characters For the purpose of keeping track of screen
appearance, ANSI color escape sequences are assumed to
not move the cursor. You can make less think that
characters other than "m" can end ANSI color escape
sequences by setting the environment variable
LESSANSIENDCHARS to the list of characters which can end
a color escape sequence. And you can make less think
that characters other than the standard ones may appear
between the ESC and the m by setting the environment
variable LESSANSIMIDCHARS to the list of characters
which can appear.

Perhaps should update Configure to set $Config{pager} to
'/usr/bin/less -R' instead of merely '/usr/bin/less' when we're using
less.

Should also update Pod::Perldoc to use `less -R'

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=library
severity=low
module=Pod::Perldoc
---
Site configuration information for perl 5.11.3:

Configured by jbenjore at Wed Dec 30 23:51:21 PST 2009.

Summary of my perl5 (revision 5 version 11 subversion 3) configuration:
Commit id: 9c3f2640bc47839fced0ccc78bae4b814ae82e97
Platform:
osname=darwin, osvers=10.2.0, archname=darwin-thread-multi-2level
uname='darwin w3m211a 10.2.0 darwin kernel version 10.2.0: tue nov
3 10:37:10 pst 2009; root:xnu-1486.2.11~1release_i386 i386 '
config_args='-des -Dcc=ccache gcc
-Dprefix=/opt/perl-5.11.3-64-thr-dbg -Dusedevel -DDEBUGGING
-Duse64bitint -Dusethreads'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='ccache gcc', ccflags ='-fno-common -DPERL_DARWIN
-no-cpp-precomp -DDEBUGGING -fno-strict-aliasing -pipe
-fstack-protector -I/usr/local/include -I/opt/local/include',
optimize='-O3 -g',
cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN
-no-cpp-precomp -DDEBUGGING -fno-strict-aliasing -pipe
-fstack-protector -I/usr/local/include -I/opt/local/include'
ccversion='', gccversion='4.2.1 (Apple Inc. build 5646) (dot 1)',
gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags ='
-fstack-protector -L/usr/local/lib -L/opt/local/lib'
libpth=/usr/local/lib /opt/local/lib /usr/lib
libs=-ldbm -ldl -lm -lutil -lc
perllibs=-ldl -lm -lutil -lc
libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup
-L/usr/local/lib -L/opt/local/lib -fstack-protector'

Locally applied patches:


---
@INC for perl 5.11.3:
/opt/perl-5.11.3-64-thr-dbg/lib/site_perl/5.11.3/darwin-thread-multi-2level
/opt/perl-5.11.3-64-thr-dbg/lib/site_perl/5.11.3
/opt/perl-5.11.3-64-thr-dbg/lib/5.11.3/darwin-thread-multi-2level
/opt/perl-5.11.3-64-thr-dbg/lib/5.11.3
.

---
Environment for perl 5.11.3:
DYLD_LIBRARY_PATH (unset)
HOME=/Users/jbenjore
LANG=en_US.UTF-8
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/Users/jbenjore/src/git-utils:/opt/perl-5.10.1/bin:/Users/jbenjore/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:/Users/jbenjore\
/src/whitepages-git-utils/
PERL_BADLANG (unset)
SHELL=/bin/bash


twists at gmail

May 23, 2011, 9:04 AM

Post #2 of 6 (146 views)
Permalink
Re: [perl #72156] perldoc should ask less to handle ANSI escapes [In reply to]

On Mon, May 23, 2011 at 8:52 AM, Dave Rolsky via RT
<perlbug-followup [at] perl> wrote:
> This is still a problem in Perl 5.14.0.

Oh drat, I'd forgotten completely about this issue. We have to treat
$Config{pager} as something to be interpreted by the shell. It's just
incorrect of us to use system(LIST).

Josh


twists at gmail

Oct 21, 2011, 11:49 AM

Post #3 of 6 (100 views)
Permalink
Re: [perl #72156] perldoc should ask less to handle ANSI escapes [In reply to]

Thanks, I'll look at this tonight. Agreed, Configure ought to be sane
and that is separable from Podlater sanity.

On Fri, Oct 21, 2011 at 11:34 AM, Tom Wyant via RT
<perlbug-followup [at] perl> wrote:
> On Mon May 23 09:04:53 2011, jjore wrote:
>> On Mon, May 23, 2011 at 8:52 AM, Dave Rolsky via RT
>> <perlbug-followup [at] perl> wrote:
>> > This is still a problem in Perl 5.14.0.
>>
>> Oh drat, I'd forgotten completely about this issue. We have to treat
>> $Config{pager} as something to be interpreted by the shell. It's just
>> incorrect of us to use system(LIST).
>>
>> Josh
>>
>
> And in the meantime Configure's default response is still unacceptable.
>
> One way to deal with this is to split off the first word of the response
> and just test that. The attached patch to Configure (diff -u against
> 5.15.4) represents one way to do that.
>
> The attached patch does _not_ correctly handle responses in which the
> pager's name contains quoted (or presumably escaped) spaces. But maybe
> someone with more sh-fu than I have can fix it up. But neither does the
> unpatched code. And even with this restriction the patched code should
> cause the "Use this anyway" question to come up less often.
>


h.m.brand at xs4all

Jul 2, 2012, 11:05 PM

Post #4 of 6 (59 views)
Permalink
Re: [perl #72156] perldoc should ask less to handle ANSI escapes [In reply to]

On Mon, 02 Jul 2012 19:54:06 -0700, "Jesse Luehrs via RT"
<perlbug-followup [at] perl> wrote:

> Pod::Perldoc has been fixed for this issue in 5.16.0, but the Configure
> change has yet to be applied.
>
> ---
> via perlbug: queue: perl5 status: open
> https://rt.perl.org:443/rt3/Ticket/Display.html?id=72156

Due to Andy's replies in that ticket, *I* never committed that (Andy
has commit to Configure too)

--
H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/
using perl5.00307 .. 5.14 porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/
http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/


doughera at lafayette

Jul 3, 2012, 8:35 AM

Post #5 of 6 (56 views)
Permalink
Re: [perl #72156] perldoc should ask less to handle ANSI escapes [In reply to]

On Tue, 3 Jul 2012, H.Merijn Brand wrote:

> On Mon, 02 Jul 2012 19:54:06 -0700, "Jesse Luehrs via RT"
> <perlbug-followup [at] perl> wrote:
>
> > Pod::Perldoc has been fixed for this issue in 5.16.0, but the Configure
> > change has yet to be applied.
> >
> > ---
> > via perlbug: queue: perl5 status: open
> > https://rt.perl.org:443/rt3/Ticket/Display.html?id=72156
>
> Due to Andy's replies in that ticket, *I* never committed that (Andy
> has commit to Configure too)

Whoops. Yes, I forgot about that one. I remember thinking that perhaps
we should undo the "less -R" trick and try to fix the problem differently,
but that time has long since passed. I'll try to push the fix in the
ticket later this week.

--
Andy Dougherty doughera [at] lafayette


doughera at lafayette

Aug 2, 2012, 12:06 PM

Post #6 of 6 (46 views)
Permalink
Re: [perl #72156] perldoc should ask less to handle ANSI escapes [In reply to]

On Tue, 3 Jul 2012, Andy Dougherty wrote:

> On Tue, 3 Jul 2012, H.Merijn Brand wrote:
>
> > On Mon, 02 Jul 2012 19:54:06 -0700, "Jesse Luehrs via RT"
> > <perlbug-followup [at] perl> wrote:
> >
> > > Pod::Perldoc has been fixed for this issue in 5.16.0, but the Configure
> > > change has yet to be applied.

> > > https://rt.perl.org:443/rt3/Ticket/Display.html?id=72156

> Whoops. Yes, I forgot about that one. I remember thinking that perhaps
> we should undo the "less -R" trick and try to fix the problem differently,
> but that time has long since passed. I'll try to push the fix in the
> ticket later this week.

Well, it was a month instead of a week, but the fix is now applied
as commit 38ab64ac881571a458ca1766a1b81fdec687b76b.

The corresponding metaconfig commit was
53ddb3ba3e23ab80444c30b4deefa64114408438.

--
Andy Dougherty doughera [at] lafayette

Perl porters RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.