I use c-shell (tcsh) as my shell; have been from 25+ years. I know, I know, bash is supposedly better, but I’ve never had issue using c-shell and it’s what I started with. Anyway, I recently switched one on my VMs to CentOS and found that the
less command insists on sourcing .cshrc. This is fine provided you don’t have any output (i.e., echo command). If you do, or have a menu selection (like I do for a certain user), then
less will just use that output versus the file you want to look at. I should note, the doesn’t appear to happen in the bourne shell (or derivatives of it), nor is it a problem in other Linux distros, but I’m not switching. To workaround the issue, I create a simple less.csh script with the following:
#!/bin/tsch -f setenv LESS_CMD 1 setenv LESS -Xe /bin/less $argv unsetenv LESS_CMD
I then add the following to the beginning of
if ($?LESS_CMD) then #echo executing less else # ... normal processing endif
I shouldn’t have to do this because I’ve never seen this behavior in any other Linux distro, or any other *NIX OS (Solaris, AIX, HPUX, etc.) for that matter either. So it seems to be something unique to how CentOS is building less that causes it to behave differently under c-shell.
And that’s all I have to say about that.