http://qs321.pair.com?node_id=243485

Ovid has asked for the wisdom of the Perl Monks concerning the following question:

I recently upgraded to RH Linux 8.0 and perldoc seems to be displaying escape sequences. It runs just fine, but output appears as follows

$ perldoc Class::DBI

Class::DBI(3)         User Contributed Perl Documentation        Class::DBI(3)


ESC[1mNAMEESC[0m
               Class::DBI - Simple Database Abstraction

ESC[1mSYNOPSISESC[0m
               package Music::DBI;
               use base 'Class::DBI';
               Music::DBI->set_db('Main', 'dbi:mysql', 'username', 'password');

(Note that "ESC" is actually white text on a black background).

Frankly, I haven't a clue on how to debug this. Is this a general Linux issue? My man pages appear fine. General info:

A quick discussion in the chatterbox has revealed that I am not the only monk to have this problem. Petruchio notes that he has a similar problem and redirecting the output to a file and examining it with a hex editor reveals that the escape sequences appear to be properly formed.

I can get around this with perldoc -t module_name, but it would be nice to get this working.

Cheers,
Ovid

New address of my CGI Course.
Silence is Evil (feel free to copy and distribute widely - note copyright text)

Replies are listed 'Best First'.
Re: Perldoc Problem: Linux or Perl?
by jasonk (Parson) on Mar 16, 2003 at 16:54 UTC

    This is a bug in the way perldoc interacts with groff (it first appeared in Red Hat Linux 8.0, becuase this is the first version with UTF-8 support), it is fixed in the latest rawhide version of Red Hat Linux (which means the fix will be in the next release), but in the meantime the easiest way to work around it is to set the environment variable LESS to 'isr'.

    There are several ways you can do this:

    For bash, add to your .bashrc: export LESS='isr'

    For csh or tcsh, add your .cshrc or .tcshrc: setenv LESS isr

    Or you can just specify it on the command line when you run perldoc: LESS=isr perldoc perlop

    Update: I should mention that only the -r option is really necessary to fix this problem, I just used -isr because that's what I have in my own settings, -i tells less to be case-insensitive when searching, and -s says to compress runs of multiple blank lines to a single blank line. The -r option causes the formatting escape codes to be passed through directly to the terminal.

    Update: Oops, has nothing to do with UTF-8, it's caused by new options in groff... The bugzilla.redhat.com entry has some more information.


    We're not surrounded, we're in a target-rich environment!
      I can't find the link - but I've read recently somwhere that interpreting escape sequences might be a security risk when you browse for example log files where there is data from external sources.
Re: Perldoc Problem: Linux or Perl?
by Elian (Parson) on Mar 16, 2003 at 16:30 UTC
    Check your pager switch environment variable. Might be that less is getting different switches set (or old switch settings were lost) because of the upgrade.
Re: Perldoc Problem: Linux or Perl?
by allolex (Curate) on Mar 16, 2003 at 23:28 UTC

    I hate to say this, but at least on my system, this problem has something to do with KDE, not with perldoc. KDE appears to have been misconfigured by Redhat so that it displays a number of escaped characters, in particular "-", as box-thingies (I do believe that is the technical term).

    Try this experiment: do ctrl-alt-whatever and pull up a console. Check there. Now start gnome-terminal and check its output. On my system, the problem only exists in Konsole (and in xterm if you don't start it with the -u8 parameter).

    And more specifically, the problem occurs with anything man-formatted in Konsole. Unfortunately, I'm not where to go from here except to check the Konsole docs to see if there's a UTF-8 setting that will fix it. I'll get back to you before the bitterness that is the whole KDE-under-Redhat debate bears its ugly fruit.

    Surprised to read that your man pages are fine.

    --
    Allolex

      It has nothing to do with KDE vs. GNOME, it's a bug in less-378-7/groff-1.18.1-20, if you upgrade to the latest version of those two packages from rawhide, the problem will go away.


      We're not surrounded, we're in a target-rich environment!

        Thanks for the advice, and the problem did go away. That still leaves the question open as to why perldoc and man ouput was formatted correctly under gnome-terminal and xterm, and not under konsole (and putty over ssh, apparently). It still looks a lot like Redhat had a workaround for Gnome and not for KDE, since it worked correctly in those environments before updating.

        Update: added text in italics above.

        --
        Allolex

      I don't think that the problem is restricted to Kconsole as I get the "...displays a number of escaped characters, in particular "-", as box-thingies..." when I use putty to ssh into a freshly installed Redhat 8 box.


      Ben Marsh