LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


View Poll Results: Would you like automatic color handling by default for "less" in Slackware?
Yes please, it makes sense more often than not 1 7.69%
No, it should be up to the admin(s) for each site 9 69.23%
It doesn't matter to me 1 7.69%
I don't understand why this is important 2 15.38%
Voters: 13. You may not vote on this poll

Reply
  Search this Thread
Old 03-21-2021, 07:02 PM   #1
gus3
Member
 
Registered: Jun 2014
Distribution: Slackware
Posts: 490

Rep: Reputation: Disabled
should default $LESS enable on-terminal color?


(Inspired by this brief thread, and the pre-beta status of Slackware 15.0.)

Enabling color in "less", on a system-wide basis, might be useful or practical for some users/sites. And maybe not.

For Bourne-type shells and zsh, LESS is set in /etc/profile to "-M". The C shell equivalent is in /etc/csh.login. This makes it a system-wide default, and of course users may override that in their personal shell startup scripts, via something like LESS="$LESS -R".

From the above thread, it would make sense to add -R to $LESS by default, in order to get "git log" to show colorization properly. But it might also result in someone asking "if 'git log | less' shows color correctly, why isn't 'dmesg | less' showing it too?" And that's perfectly valid; dmesg writes color codes to a terminal, but not to a pipe.

Yes, it's possible to edit /etc/profile et al., but what happens during an upgrade of Bash or Tcsh? It's up to the admin to remember "oh yeah, LESS was customized" and even if that was the only customization, it blocks a new profile/csh.login from getting installed. That new script might include a security fix. Installing the new script, with a customized $LESS, makes just one more customization that has to get carried over.

Am I over-thinking this? Of course I am. But I want to present some pro/con points.

Another reason I'm bringing up this question now, is that we're gearing up for the 15.0 release, and that's the best time to make such a tweak to default settings.

So, what are your thoughts out there? Would you like our BDFL to add automatic color-handling to "less"?

Side note to our BDFL: your ruling is final, and a pox on anyone who says otherwise.
 
Old 03-21-2021, 09:11 PM   #2
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
IMO, No.

-R is a potential security vulnerability as it opens less up to some of the same issues that viewing a file with 'more' or 'cat' has. i.e. it makes it possible to hide malicious code in script/source files.

Probably not a good idea to enable it out of the box for this reason.

That said I use LESS=-MRFX here, but I do so knowing the implications.
 
1 members found this post helpful.
Old 03-22-2021, 06:38 AM   #3
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
Quote:
Yes, it's possible to edit /etc/profile et al., but what happens during an upgrade of Bash or Tcsh?
The /etc/profile file is supplied in the etc package. It comes in with a .new file. An administrator needs to handle such a file.
Quote:
For Bourne-type shells and zsh, LESS is set in /etc/profile to "-M". The C shell equivalent is in /etc/csh.login. This makes it a system-wide default, and of course users may override that in their personal shell startup scripts, via something like LESS="$LESS -R".
Exactly.
From 'man bash'
Quote:
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.
From 'man zshall'
Quote:
Login shells source /etc/profile followed by $HOME/.profile
So, perhaps a custom ~/.profile would meet your need without any changes to /etc/profile.

Oh, I am voting No.

Last edited by allend; 03-22-2021 at 06:40 AM.
 
1 members found this post helpful.
Old 03-22-2021, 07:27 AM   #4
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
IMO, the only thing the stock /etc/profile should be doing is to ensure a sensible PATH and umask value, and then source the profile.d/ members. Any additional vendor customisations could then be placed in a profile.d/aaa_slackware.sh which could, if required, easily be disabled by the user with a good old chmod -x in the usual slackware fashion.

But, as allend says, it's easy enough to override things from the other shell init files, or just manage /etc/profile yourself. I've reworked both my etc/profile and xdm/Xsession into something a little nicer, so I'm used to dealing with it when Pat changes something in there.

I don't pay much attention to any of the *.csh in there as I never use that shell.

Last edited by GazL; 03-22-2021 at 07:30 AM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: 179 Color Schemes For Your Gtk-Based Linux Terminal (Gnome Terminal, Tilix, Xfce Terminal, More) LXer Syndicated Linux News 0 07-28-2019 04:50 AM
New install Xubuntu 14.04 trying to replace default terminal with Terminator error:Failed to execute default Terminal Emulator bdalzell Ubuntu 2 06-19-2016 04:40 AM
default to | less in terminal muddywaters Linux - General 1 05-21-2006 05:15 AM
less(1) keystrokes gather on command line when less called in script from .bash_profi TimberT Linux - Newbie 7 06-30-2004 01:23 AM
Needed CD-Less/Floppy-Less install solution jnunezNYC Linux - Software 11 07-16-2001 09:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 07:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration