Bug 146242

Summary: piping ls command into less shows weird line controls
Product: [Fedora] Fedora Reporter: Joachim Backes <joachim.backes>
Component: lessAssignee: Jindrich Novy <jnovy>
Status: CLOSED NOTABUG QA Contact: Mike McLean <mikem>
Severity: medium Docs Contact:
Priority: medium    
Version: 3CC: jnovy, pknirsch
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-07-04 13:53:00 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Joachim Backes 2005-01-26 12:13:22 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5)
Gecko/20041111 Firefox/1.0

Description of problem:
Try a "ls -l|less" gives the following output:

ESC[0mESC[01;34mAnleitungenESC[0m
ESC[01;34mC++ESC[0m
ESC[01;34mCrossoverOfficeESC[0m
ESC[01;34mDesktopESC[0m
ESC[01;34mInhalte-RH-EL-AS3-CDsESC[0m
ESC[01;34mOffice-DokumenteESC[0m
ESC[01;34mRPMSESC[0m
ESC[0mXrootenv.0ESC[0m
ESC[0mair.midESC[0m
ESC[01;34mbiosESC[0m
ESC[0mbioscomp.pdfESC[0m
ESC[0mctbios15.zipESC[0m
ESC[01;34mcxofficeESC[0m
ESC[0mgoldberg.midESC[0m
ESC[01;34mhorror_cESC[0m
ESC[01;34miconsESC[0m
ESC[01;34moffice7.0ESC[0m
ESC[0mrandp.pdfESC[0m
ESC[01;34mscriptsESC[0m
ESC[01;34mselfhtmlESC[0m
ESC[0mtelefonbuch.ps.gzESC[0m
ESC[0mtest.cESC[0m
ESC[0mtest.oESC[0m

But Try a "ls -l|more" gives the following correct output:

Anleitungen
C++
CrossoverOffice
Desktop
Inhalte-RH-EL-AS3-CDs
Office-Dokumente
RPMS
Xrootenv.0
air.mid
bios
bioscomp.pdf
ctbios15.zip
cxoffice
goldberg.mid
horror_c
icons
office7.0
randp.pdf
scripts
selfhtml
telefonbuch.ps.gz
test.c

THis happens either on the console or a gnome-terminal. The behaviour
is new in FC3 and did not appear in FC2


Version-Release number of selected component (if applicable):
less-382-4

How reproducible:
Always

Steps to Reproduce:
1.Pipe ls output into less
2.
3.
    

Actual Results:  Weird control chars

Expected Results:  no weird controls

Additional info:

Comment 1 Jindrich Novy 2005-01-26 14:21:08 UTC
This works for me with less-382-4 in gnome-terminal.

This looks like you terminal refuses to interpret escape sequences
properly. Which one do you use?

Comment 2 Joachim Backes 2005-01-26 14:34:07 UTC
On the console, I have TERM=linux-c.
gnome-terminal is started in a gnome session, and inside
gnome-terminal, I have TERM=xterm, and the other settings in
gnome-terminal are:

BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_ENV=/usr/people/backes/.bashrc
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="00" [2]="14" [3]="1" [4]="release"
[5]="i386-redhat- linux-gnu")
BASH_VERSION='3.00.14(1)-release'
COLORTERM=gnome-terminal
COLUMNS=80
DIRSTACK=()
DISPLAY=:0.0
EUID=1001
GNOME_DESKTOP_SESSION_ID=Default
GNOME_KEYRING_SOCKET=/tmp/keyring-EJMYGr/socket
GROUPS=()
GS_LIB=/usr/share/fonts/default/Type1
GTK_RC_FILES=/etc/gtk/gtkrc:/usr/people/backes/.gtkrc-1.2-gnome2
G_BROKEN_FILENAMES=1
HISTFILE=/usr/people/backes/.bash_history
HISTFILESIZE=1000
HISTSIZE=1000
HOME=/usr/people/backes
HOSTNAME=sunny.rhrk.uni-kl.de
HOSTTYPE=i386
IFS=$' \t\n'
INPUTRC=/etc/inputrc
KDEDIR=/opt/kde
LANG=en
LC_ALL=C
LESSCHARSET=latin1
LESSOPEN='|/usr/bin/lesspipe.sh %s'
LINES=24
LINGUAS=en
LOGNAME=backes
LS_COLORS=
MACHTYPE=i386-redhat-linux-gnu
MAIL=/var/spool/mail/backes
MAILCHECK=60
MANPATH=/usr/man:/usr/share/man:/usr/local/man:/usr/X11R6/man:/usr/local/share/m
an:/opt/schily/man
MM_CHARSET=ISO-8859-1
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/kerberos/bin:/opt/schily/bin:/bin:/usr/bin:/usr/local/bin:/bin:/usr/bi
n:/usr/X11R6/bin:/usr/adsm:/opt/kde/bin:/sbin:/usr/sbin:/usr/rhrk::/usr/local/Ac
robat5/bin:/usr/local/jdk1.2.2/bin:/opt/tivoli/tsm/client/ba/bin:/opt/tivoli/tsm
/client/admin/bin:/usr/local/matlab-14sp1/bin:/usr/local/netscape:/usr/bin/mh:/u
sr/people/backes/bin:/usr/people/backes/scripts:/usr/people/backes/scripts/Login
:/usr/people/backes/cxoffice/bin
PIPESTATUS=([0]="0")
PPID=11644
PS1='\[\033[7m\]\u@\h\[\033[m\] [\W]: '
PS2='> '
PS4='+ '
PWD=/usr/people/backes
QTDIR=/usr/lib/qt-3.3
SESSION_MANAGER=local/sunny.rhrk.uni-kl.de:/tmp/.ICE-unix/4982
SHELL=/bin/bash
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:moni
tor
SHLVL=4
TAPE=/dev/nst0
TERM=xterm
UID=1001
USER=backes
USERNAME=
WINDOWID=18888633
XAUTHORITY=/usr/people/backes/.Xauthority
_=xterm
font=-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso8859-1
iconFont=-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso8859-1
menuFont=-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso8859-1
terminalFont=-adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1


Comment 3 Jindrich Novy 2005-01-26 20:18:53 UTC
Suggest setting LESSCHARSET=utf-8. Do you see display problems with
LESSCHARSET=latin1? Is the issue present for either console or
gnome-terminal?

Comment 4 Joachim Backes 2005-01-27 07:37:36 UTC
setting LESSCHARSET=utf-8 does not help. Setting LESSCHARSET=latin1
does not help too.

The issue is present for both console and gnome-terminal (and xterm too)

Comment 5 Jindrich Novy 2005-01-27 17:21:35 UTC
I have no clue where the problem is. Ray could you help?

Comment 6 Ray Strode [halfline] 2005-01-27 23:20:00 UTC
Hi Jindrich,

To reproduce this problem run:

ls -l --color | less

(the reporter may have an alias setup, i'm not sure)

So it seems less is filtering out the escape sequences and printing
out what they are.  According to the less man page -R prevents this
from happening.  Indeed,

ls -l --color | less -R

seems to work fine.  It's possible that less used to default to -R but
now doesn't or our configuration of less changed between FC2 and FC3.
 I don't know.  You might want to verify that the behavior changed
between FC2 and FC3, look through the changes between FC2 and FC3 in
the spec file and the upstream changelog to see if any defaults
changed and if so why, and change back the behavior if it was changed
and there wasn't a good reason for it being changed.  



Comment 7 Joachim Backes 2005-01-28 05:48:50 UTC
Hi,

indeed my ls is an alias:

alias ls
alias ls='ls --color '

Now,
\ls -l |less is running correctly, and ls -l|less -R
too.

Comment 8 Jindrich Novy 2005-07-04 13:53:00 UTC
I see from the FC2/FC3 specs that the upstream version hasn't changed and the
packages are identical for both the versions. Please add alias less='less -R'.
This is a specific configuration problem and doesn't affect FC3 users.