Linux version 2.6.18-92.1.17.el5 (brewbuilder@hs20-bc1-7.build.redhat.com) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)). I am using csh but have the same problems on bash.
If I pipe something to less it works perfectly i.e. cat file | less
However if I do, less file, nothing happens apart from getting a new prompt line that doesn't display what I'm typing. If I type exit and press enter then I get the less output.
I was using less 394 and compiled less 429 on my system, but it had the same problem.
I looked on the less page FAQ (Less FAQ) but couldn't find anything useful.
When on the receiving end of a pipe less generates output. With less filename you have to play with ^V the space bar and so on. You are in interactive mode.
It's behavior depends on the terminal "type" of stdin. In a script or on the receiving end of a pipe, stdin is not a terminal. less uses termcap based on terminal type to determine base behavior when it is entered on the command line.
Thanks Jim for the reply. I got your point of less behaving differently when executed directly from the terminal and when piped.
I am confused about what you mean by interactive mode. I can get into interactive mode, only when I pipe stdin to less. But when I execute less directly from the terminal, the screen is seemingly frozen and I can't get into interactive mode. When I say that the screen is seemingly frozen, I mean my typing isn't displayed, the same behaviour when you type in password. I hope I haven't confused you.
I can get out of this "frozen stage" when I type exit and then I get into the interactive mode of less. It seems like when I type "less" I change the terminal control to not display what I'm typing.
I compiled different versions of less and ran it with (-X, which is my favourite parameter) and without additional parameters and it had the same problems outlined above.
But no there weren't any aliases set up at the time I had my problems.
Do you see any correlation between the shell and less, which might have caused my problems?
no. that just sounds weird. are you 100% sure no aliases or wrapper scripts exist? Are there any less environment variables set only in csh? it's hard to say without more details but sounds like a possible environment issue.
Unfortunately (or fortunately), once the sys admin changed my passwd entry on the LDAP server (?) back to /bin/bash (it was previously on /bin/csh when I did getent), less works on csh. So I can't replicate the error.