Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 17660 - cwdcmd settings in new tcsh cause problems with lesspipe.sh portion of less
Summary: cwdcmd settings in new tcsh cause problems with lesspipe.sh portion of less
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Fabian Groffen
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-16 21:10 UTC by Joseph Tucek
Modified: 2005-09-30 12:33 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Tucek 2003-03-16 21:10:28 UTC
After emerging the new tcsh, less stopped working.  After a lot of poking
around, I found that less runs the script specified by the LESSOPEN command
(default in Gentoo is lesspipe.sh) as an input filter.  It uses some non-obvious
code to determine exactly what command to pass to system(...), but it appears to
run 
$SHELL -c "lesspipe.sh <file>"
If $SHELL is /bin/tcsh, this results in cwdcmd to be aliased to something (it's
intended to update the titlebar of GUI terminals, and varies with $TERM), and
then tcsh being instantiated.  tcsh will run cwdcmd, which will print something
out (usually of the form <CONTROL CHARACTERS>$cwd), which gets in the input
stream of less (as if lesspipe.sh put it there), thereby mucking up less.

less doesn't produce any output other then the output of cwdcmd on ordinary
files, and outputs the cwdcmd output and then the output of lesspipe.sh on
"special" files (*.gz, *.bz2, and other extensions).

Reproducible: Always
Steps to Reproduce:
1.Have $SHELL be /bin/tcsh (probably needs to be exported as well).

2.Have /etc/profile.d/tcsh-settings alias cwdcmd to output something non-null. 
The default of the new tcsh ebuild should be fine.

3.Run "less foo.txt".  Also try "less foo.txt.gz".

Actual Results:  
On an ordinary VC, the output of "less foo.txt" is "Directory: $cwd".

With KDE's konsole, the output of "less foo.txt" is "^G".

On an ordinary VC, the output of "less foo.txt.gz" is "Directory: $cwd" followed
by what one would expect (gzip -dc foo.txt.gz|less).

With konsole, the output is as with a VC, but with "^G" instead of "Directory..."

Expected Results:  
Try it with a stock bash.

A fix is to just not use cwdcmd.  Most other distro's set GUI terminal titlebars
by playing with the prompt.  This is arguably much much more correct then
aliasing cwdcmd.

'emerge info' follows

Portage 2.0.47-r10 (default-x86-1.4, gcc-3.2.2, glibc-2.3.1-r2)
=================================================================
System uname: 2.4.19-gentoo-r10 i686 AMD Athlon(tm) processor
GENTOO_MIRRORS="ftp://ftp.snt.utwente.nl/pub/os/linux/gentoo/ 
http://gentoo.oregonstate.edu/
ftp://sunsite.doc.ic.ac.uk/packages/linux/sunsite.unc-mirror/distributions/gentoo
http://www.ibiblio.org/pub/Linux/distributions/gentoo"
CONFIG_PROTECT="/etc /var/qmail/control /usr/share/config
/usr/kde/2/share/config /usr/kde/3/share/config
/usr/X11R6/lib/X11/xkb:/usr/kde/3.1/share/config:/usr/share/config"
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d"
PORTDIR="/usr/portage"
DISTDIR="/usr/portage/distfiles"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR_OVERLAY=""
USE="libg++ mikmod libwww motif 3dnow aalib acpi afs also apm arts avi berkdb
bonobo cdr crypt cups dga doc dvd encode esd evo gb gd gdbm ggz gif gnome gpm
gtk gtkhtml guile imap imlib java jpeg junit kde kerberos leim mbox mmx mozilla
mpeg ncurses nls oggvorbis opengl oss pam pdflib perl pic plotutils png python
qt qtmt quicktime readline samba sdl slang spell ssl svga tcltk tcpd tetex tiff
truetype X xml xml2 xmms xv zlib x86"
COMPILER="gcc3"
CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon-tbird -O3 -pipe -fforce-addr -fomit-frame-pointer
-funroll-loops -falign-functions=4 -maccumulate-outgoing-args"
CXXFLAGS="-march=athlon-tbird -O3 -pipe -fforce-addr -fomit-frame-pointer
-funroll-loops -falign-functions=4 -maccumulate-outgoing-args"
ACCEPT_KEYWORDS="x86"
MAKEOPTS="-j1"
AUTOCLEAN="yes"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
FEATURES="sandbox ccache"
Comment 1 Wayne Davison 2003-04-06 06:35:37 UTC
I'm curious what the value of $LESSOPEN is on your system.  It is set to
"|lesspipe.sh %s" on my system, which causes the script to be run by /bin/sh
(since the first line of the script is #!/bin/sh).  Is $LESSOPEN different
on your system?  If not, I don't see how tcsh is getting involved in this
situation.  I run zsh, and the $SHELL setting is not entering into the
equation when less calls out to lesspipe.sh.  (I didn't try using tcsh,
however.)
Comment 2 Wayne Davison 2003-04-06 14:47:06 UTC
After checking the less source code (which I should have done before the last
comment) I see now where the $SHELL usage is coming in.  One easy fix for tcsh
users is to add "SHELL=/bin/sh" into their ~/.lesskey file so that less uses
/bin/sh to run the LESSOPEN command rather than using tcsh.
Comment 3 MKI 2004-08-21 17:07:15 UTC
Also, the cwdcmd alias causes tcsh to print Directory: $pwd twice on simple
operations that one could care less about the current directory location.

eg.

Password:
Last login: Sat Aug 21 16:57:27 2004 from [...]
Directory: /home/brad
Directory: /home/brad
5:09pm /home/brad> cd
Directory: /home/brad
5:09pm /home/brad>


If someone could please remove cwdcmd alias, it sure would be appreciated.
Comment 4 Fabian Groffen gentoo-dev 2005-09-13 11:23:25 UTC
I think it should be gone, including the cd . that is done afterwards to print
the current directory.  In my proposed patch on bug #89295 both are replaced by
a prompt setting
Comment 5 Fabian Groffen gentoo-dev 2005-09-27 11:49:04 UTC
note to self: done
Comment 6 Fabian Groffen gentoo-dev 2005-09-30 12:33:01 UTC
Fixed in 6.14-r1