OpenSolaris

Printable Version Enter a New Search
Bug ID 6622763
Synopsis Fix for 6569261 broke less(1) for xterm-type windows
State 11-Closed:Not a Defect (Closed)
Category:Subcategory utility:terminal
Keywords
Responsible Engineer Stacey Marshall
Reported Against snv_76
Duplicate Of
Introduced In
Commit to Fix
Fixed In
Release Fixed
Related Bugs 6569261
Submit Date 29-October-2007
Last Update Date 12-November-2007
Description
[New description after moving this CR from solaris/utility/less to
solaris/utility/terminal.]

Starting in snv_76, the following problems occur when using the
less(1) and more(1) commands in a terminal window with TERM type
"xterm", such as gnome-terminal:

  1) When one types "q" to exit either less(1) or more(1) while
     displaying a window-full of text, the pager program clears the
     window and redisplays the window contents from prior to the
     invocation of the pager program.  This extremely annoying problem
     means that one can no longer refer back to pager output either
     visually or for copy/paste at the command line within the same
     window.

  2) "less -E" of input containing fewer lines than the terminal
     window has rows returns without displaying any of the input.

Replacing the system's termcap/terminfo databases by ones built from
sources after backing out the changes putback for 6569261 restores the
expected behavior of less(1) and more(1) in xterm-type windows.
you probably should add more info (like terminal type
at least) as I did a quick check and didn't see this on a test
machine. which isn't too surprising given less itself hasn't
changed for a long long time (I elfcmp'd the binary on my sparc
desktop from May 10 with the latest and there is no difference).
However terminfo entries may affect it, like fixes in 76 for 
6569261. Just a guess though.
Good point.  This problem occurred in gnome-terminal windows in the
JDS in snv_76.  I believe the TERM type was "xterms" (I'm on a SunRay
running s10 now and can't double check).  I'll be installing snv_76 on
a SPARC system tomorrow and will check there as well.
So I noticed that this does affect my machines running
the latest bits, but only if I use the xterm type (even running in
a dtterm or putty window). testing 'sun' or 'dterm' shows
no problems, but setenv TERM to xterm and boom. In a dtterm
you can see it's not doing 'no output' but is clearing the
screen at least (but whatever it's trying to do doesn't
give the expected output clearly).

If I undo the change to cmd/terminfo/pc.ti, which was this:

D 1.16  07/09/26 08:57:11 as145665      28 27   00007/00007/00874
6569261 xterm, xtermc, xterm-color: smcup/rmcup definitions are incorrect/missing

5,7c5,6
< # Common Development and Distribution License, Version 1.0 only
< # (the "License").  You may not use this file except in compliance
< # with the License.
---
> # Common Development and Distribution License (the "License").
> # You may not use this file except in compliance with the License.
23a23,26
> #
> # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
> # Use is subject to license terms.
> #
25,28d27
< 
< # Copyright (c) 1999 by Sun Microsystems, Inc.
< # All rights reserved.
< 
595a595
>         rmcup=\E[2J\E[?47l\E8, smcup=\E7\E[?47h,

then it works again.

even a newer version of less (394) behaves the same way.
So I'm not sure this is a less bug, it looks more like a bug
in the terminfo change?
The gnome-terminal TERM type is "xterm" (not "xterms", as I had
misremembered).  Other aspects of this problem are:

  - /usr/bin/more, whose default behavior matches the "-E" behavior
    of /usr/bin/less, still properly displays files with fewer lines
    than the terminal has rows.

  - An even more obnoxious symptom is that, when used in an xterm-type
    window, both "less" and "more" clear the window and redisplay the
    old window contents when "q" is typed while displaying a
    window-full of data.  Neither "less" nor "more" behave this way
    in a dtterm-type window in snv_76 (or in an xterm-type window
    prior to snv_76).
The functionality described has always been there, its just that CR
6569261 has fixed the terminfo database and thus we are now seeing the
functionality.

If you don't want this functionality from 'less' then set LESS
environment variable to '-X':

     -X or --no-init
          Disables sending the termcap initialization and  deini-
          tialization strings to the terminal.  This is sometimes
          desirable if the deinitialization string does something
          unnecessary, like clearing the screen.

In my testing the 'more' command is not affected.

The man(1) command uses environment variable PAGER which if set to
'less' (less is more) then you will also need to LESS as above.

Alas I don't see an option to 'vi' to prevent this feature.
Work Around
The old behavior can be restored when using less by specifying -X.  I'm unaware
of similar workarounds for other utilities though.
modify .profile and or .cshrc accordingly:

$ grep -i less $HOME/.profile
PAGER=less
LESS=-X
export PAGER LESS
$

$ get -i less $HOME/.cshrc
setenv PAGER=less
setenv LESS=-X
Comments
N/A