Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i experience for a while a strange problem with the LESS command : each time i invoke it it wants to read my shell startup scripts, currently ~/.bash_profile, ~/.bashrc and so on. not only will that cost execution time but if there is an output from calling bash it will screw my less output. i am unable to locate where or why LESS wants to re-read my bash login scripts - instead of directly inherit the run parameters from the running shell.
Noting that this is written by someone who never uses less ...
Have you investigated what gets called when you invoke less?
I mean, it's a command line binary. It does the opposite of more, which is also a command line binary.
I do a which and then subsequent ls -l, I see the following. I run Mint:
Code:
$ which less
/usr/bin/less
$
$ ls -l /usr/bin/less
lrwxrwxrwx 1 root root 9 Jun 6 17:13 /usr/bin/less -> /bin/less
$
$ ls -l /bin/less
-rwxr-xr-x 1 root root 170728 Apr 5 2017 /bin/less
$
$ less --version
less 481 (GNU regular expressions)
Copyright (C) 1984-2015 Mark Nudelman
less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Homepage: http://www.greenwoodsoftware.com/less
$
i have the same version of LESS on my box(es). it's located at /usr/bin/less but that shouldn't matter here.
i didn't change my system for 2 years but my bash files got changed evidently over the years. it's some environment variable that makes LESS read my bash files - but which one ?
As an example, I said to myself, "They are stating that it is running their profile script ... hmmm that's bash stuff. OK, well I can turn on verbose, debug output from bash and see if I see anything ..."
So I typed "set -xv" at my bash prompt to show me more output, and then typed "less file[TAB]" (for name completion), and the shell went SWOOSH showing a bunch of stuff, but I typed it fast, not expecting that, and had hit enter to go into less.
"O ... K .... what was THAT?" So I exited less and pulled back my command prompt history. I found that all the stuff printed out was shell debug, and it was shell debug due to the command completion action.
So I next typed "less filename-all-typed-in-correctly-by-me.txt" and it did absolutely nothing except entered the less program.
That's one way to tell me that I do not see any shell execution other than what I typed, as part of that command evolution.
I do not feel that there is any environment variable which affects less.
The manpage for less lists 33 environment variables that affect its operation, though I don't see anything obvious that might cause a bunch of extra files to be opened.
ok, LESS problem solved : i had an text output (echo blabla) in one of my BASH setup files, first with a color output which gave the LESS variable this strange "-M" output :
Quote:
echo $LESS
-M
echo $LESS | wc
1 1 3
but taking out the colors didn't help much either as the output continued to disturb LESS. entirely removing this "echo something" solved the problem --> /usr/bin/less works again !
what worries me still is that if there is something to slow down the reading of my BASH setup files then that will also make LESS slow or sluggish... why are my BASH files read each time when LESS is invoked ?
i am a bit puzzled with this less/bash problem. i checked this scenario on several unrelated linux boxes (all running Slackware 14.2) with several user accounts : whenever there is a verbose output from bash files (for example in ~/.bashrc) then LESS will fail and not show a text file in question ("hello world") but show bash's output string ("bash hello world").
i don't know how to interpret these strace outputs - therefore i include here two such outputs. the 1st one without bash echo :
the problem is somewhere around 'read(4...', with values of 0 (GOOD) or 1 (BAD, the letter "b" comes from the bash output).
Code:
read(4, "", 1) = 0
Code:
read(4, "b", 1) = 1
i know for a fact that the bash files get re-read with each call of /usr/bin/less - on each machine and for each user tested. why is this the case ? is it a Slackware 'feature' ?
i begin to realize that there is a lesspipe.sh pre-processor script involved here. that's perhaps something Slackware specific... there is also a LESSOPEN environment variable that makes lesspipe.sh conveniently open all kind compressed files before /usr/bin/less is invoked :
Code:
LESSOPEN=|lesspipe.sh %s
here the strace output you MadeInGermany asked for :
Code:
strace -o outputfile -s 128 -f -e execve,clone less test_less
And of course any "bash"isms need to be removed from /usr/bin/lesspipe.sh.
Now, somehow you trigger the bug.
Perhaps you have set BASH_ENV to something?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.