Red Hat Bugzilla – Bug 190619
lesspipe.sh can reference unassigned DECOMPRESSOR var
Last modified: 2007-11-30 17:11:31 EST
Description of problem:
When using the redhat less rpm's /usr/bin/lesspipe.sh, you can reference
DECOMPRESSOR when it is unassigned. This happens when viewing a normal file
that is not a .gz or .bz2 file (see the * case in lesspipe.sh).
Normally this fails silently and less takes the empty output to mean that it
should use its default behavior and open the file itself, but if using csh and
you have 'printexitvalue' set, the shell will output 'Exit 127' when it tries to
execute -- (the first thing after the reference to the undefined DECOMPRESSOR).
less sees this output from lesspipe.sh and assumes lesspipe.sh has done the
proper processing. So all the user sees when he calls less is the 'Exit 127'
(the output from 'csh -c /usr/bin/lesspipe.sh ...') and not the file he wanted
to view (whatever it may be).
This could be fixed a number of ways...
- don't set printexitvalue if not in an interactive shell.
- have less only use stdout from lesspipe.sh (it may already do that) and have
csh print the exit value to stderr
But lesspipe.sh should really not try to use an unassigned variable.
The fix is easy. See attached patch.
Version-Release number of selected component (if applicable):
less-394 rpm (and probably earlier versions as well).
Steps to Reproduce:
1. echo set printexitvalue > /tmp/.cshrc
2. env -i SHELL=/bin/csh HOME=/tmp LESSOPEN="|/usr/bin/lesspipe.sh %s"
TERM=xterm less /tmp/.cshrc
Created attachment 128571 [details]
patch to lesspipe.sh to keep from referencing undef DECOMPRESSOR
Thanks. This problem is fixed in less-394-4.
*** Bug 191308 has been marked as a duplicate of this bug. ***