Bug 190619 - lesspipe.sh can reference unassigned DECOMPRESSOR var
lesspipe.sh can reference unassigned DECOMPRESSOR var
Product: Fedora
Classification: Fedora
Component: less (Show other bugs)
All Linux
medium Severity low
: ---
: ---
Assigned To: Ivana Varekova
Mike McLean
: 191308 (view as bug list)
Depends On:
  Show dependency treegraph
Reported: 2006-05-03 20:04 EDT by John Hein
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2006-05-04 10:20:57 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
patch to lesspipe.sh to keep from referencing undef DECOMPRESSOR (340 bytes, patch)
2006-05-03 20:04 EDT, John Hein
no flags Details | Diff

  None (edit)
Description John Hein 2006-05-03 20:04:46 EDT
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).

How reproducible:

Every time.

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
Actual results:

'Exit 127' 
/tmp/.cshrc (END)

Expected results:

set printexitvalue
/tmp/.cshrc (END)

Additional info:
Comment 1 John Hein 2006-05-03 20:04:46 EDT
Created attachment 128571 [details]
patch to lesspipe.sh to keep from referencing undef DECOMPRESSOR
Comment 2 Ivana Varekova 2006-05-04 10:20:57 EDT
Thanks. This problem is fixed in less-394-4.
Comment 3 Ivana Varekova 2006-05-11 08:52:08 EDT
*** Bug 191308 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.