PDA

View Full Version : Annoying 'less' and 'man' behavior on exit



greimer
20th November 2006, 06:44 PM
I don't know if this behavior is specific to Fedora & RH, or if it applies to other Linux distributions. But I do know that I find the 'Less' and 'man' commands far less useful on Linux than on Solaris (with which I'm more familiar) , because on our RH Linux systems these commands insist on restoring the screen when I exit the command!

Typically I type 'man sometopic' or 'less somefile' because I don't know how to do something that I need to do, and I expect that the manpage or text file will offer me some insight or some example that will prove useful. I'm used to paging through the documentation, and if I'm lucky finding some nugget of information or better yet some command example that tells me how to do what I've been trying to do. "Aha!" I say to myself, and '^c' or ':q' out of my 'man' or 'less' page, cut & paste or retype the golden example that I've found (or perhaps re-tyope the command I've been trying to run according to the newly-found instructions which are now before my eyes) and accomplish what I've been trying to do.

At least, that's what I'm used to under Solaris. Under RH Linux the above scenario disintegrates at the point that I type '^c' or ':q', because 'less' or 'man' CLEARS THE SCREEN, erasing my newly-discovered insight, and restoring the terminal window to it's state after I typed the 'man' or 'less' command!

Now, if I really need that information I'll pipe my 'man' command to a temp file and use 'more' to view it (or just use 'more' instead of 'less'), find again what I found the first time (though sometimes 'man' formats it's output differently when redirected to a file) and then continue as before, but I find this an annoying and unnecessary inconvenience.

Indeed, this behavior of 'man' and'less' under Linux renders the 'less -F' option (quit if the entire file fits on one screen) useless! ex:

zen:~> echo AAAAAAAAAAAA >> junk ( Make test file )
zen:~> echo AAAAAAAAAAAA >> junk
zen:~> echo AAAAAAAAAAAA >> junk
zen:~> echo AAAAAAAAAAAA >> junk
zen:~> cat junk ( Here it is...)
AAAAAAAAAAAA
AAAAAAAAAAAA
AAAAAAAAAAAA
AAAAAAAAAAAA
zen:~> less -F junk ( But you can't see it with 'less -F' !! )
zen:~> less -F junk
zen:~> less -F junk
zen:~>

Under Solaris it's convenient to alias 'less' this way, but not under Linux!

Again, I'm new to Linux, and I don't know if this behavior is scpecific to the RH compilations of the 'less' and 'man' executables, the Gnome GUI, or soemthing else. Is there any way to change this behavior so that 'man' and 'less' just LEAVE THE TERMINAL WINDOW ALONE on exit??

dishawjp
20th November 2006, 10:14 PM
I don't know of any way to alter the behavior of the "man" command, but all of the Linux versions I've used behave this way. Redirecting the output to a file e.g., "man chmod > nnn" would work, and then using more, less or grep on the file are all options. But as you stated, this is inconvenient behavior at times.

Since I usually am running Xwindows, I work around it by having multiple terminal windows open and bouncing between the two.

I appreciate your frustration. I worked with SunOS and Ultrix (oh, and Coherent too) before moving to Linux, and had kind of forgotten that this behavior in Linux is different and have just learned to work around it.

But if you are using Xwindows, the easiest workaround is multiple terminal windows.

HTH,

Jim

greimer
20th November 2006, 10:36 PM
Well, at least I know I'm not the only person to run afoul of this quirk! Yes, multiple windows is an easier solution than piping to a file. Thanks for the reply. It would be interesting to hear from someone who knows if this was a conscious decision and if so why. Sometimes I think it might have been done on purpose to get you to stop using 'man' in favor of 'info' or the web....

mwette
21st November 2006, 02:02 AM
If I remember right the behavior you talk about is (or was at one time)
kept in the termcap entry. Nowadays, we everything is System V
based and it may be trapped in the terminfo database. There is a
chance that you could get the old behavior by knowing the right
environment variable (TERMINFO, TERMCAP?) and value to set up.

Nanook
15th January 2009, 09:45 AM
I don't know if this behavior is specific to Fedora & RH, or if it applies to other Linux distributions. But I do know that I find the 'Less' and 'man' commands far less useful on Linux than on Solaris (with which I'm more familiar) , because on our RH Linux systems these commands insist on restoring the screen when I exit the command!


Odd, I've run into exactly the opposite; after "upgrading" from Redhat 6.2 to Aurora 2.99 (based upon Fedora Core 6), I've run into an issue where if part of the man page is underlined, or inverse video, or has other attributes and I exit at that point, it leaves my screen in that mode.

Wayne
15th January 2009, 09:47 AM
And you're replying to this very dead three year old thread because..... ?

Thread closed as there are enough ghosts around already :)

Wayne