From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: app-shells/bash/files/
Date: Wed, 3 Feb 2016 18:52:02 +0000 (UTC) [thread overview]
Message-ID: <1454525501.a70b06857fc83ef6f85a6c06b3478c0c25ec8fda.vapier@gentoo> (raw)
commit: a70b06857fc83ef6f85a6c06b3478c0c25ec8fda
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 2 22:11:11 2016 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Wed Feb 3 18:51:41 2016 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a70b0685
app-shells/bash: bashrc: avoid always exporting default LS_COLORS
We've long been exporting the LS_COLORS variable to the default env,
but in practice, there's no reason to be doing this in the majority
of cases. The value we most often load is equivalent to the default
which means we're polluting the env and adding overhead for no gain.
Add a little more code (and one extra `dircolors` exec unfortunately)
to check to see if the LS_COLORS value we found is the default. If
so, don't bother exporting it anymore.
app-shells/bash/files/bashrc | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/app-shells/bash/files/bashrc b/app-shells/bash/files/bashrc
index 414f848..1107f43 100644
--- a/app-shells/bash/files/bashrc
+++ b/app-shells/bash/files/bashrc
@@ -58,13 +58,37 @@ if type -P dircolors >/dev/null ; then
# Enable colors for ls, etc. Prefer ~/.dir_colors #64489
LS_COLORS=
if [[ -f ~/.dir_colors ]] ; then
+ # If you have a custom file, chances are high that it's not the default.
+ used_default_dircolors="no"
eval "$(dircolors -b ~/.dir_colors)"
elif [[ -f /etc/DIR_COLORS ]] ; then
+ # People might have customized the system database.
+ used_default_dircolors="maybe"
eval "$(dircolors -b /etc/DIR_COLORS)"
else
+ used_default_dircolors="yes"
eval "$(dircolors -b)"
fi
- [[ -n ${LS_COLORS:+set} ]] && use_color=true
+ if [[ -n ${LS_COLORS:+set} ]] ; then
+ use_color=true
+
+ # The majority of systems out there do not customize these files, so we
+ # want to avoid always exporting the large $LS_COLORS variable. This
+ # keeps the active env smaller, and it means we don't have to deal with
+ # running new/old (incompatible) versions of `ls` compared to when we
+ # last sourced this file.
+ case ${used_default_dircolors} in
+ no) ;;
+ yes) unset LS_COLORS ;;
+ *)
+ ls_colors=$(eval "$(dircolors -b)"; echo "${LS_COLORS}")
+ if [[ ${ls_colors} == "${LS_COLORS}" ]] ; then
+ unset LS_COLORS
+ fi
+ ;;
+ esac
+ fi
+ unset used_default_dircolors
else
# Some systems (e.g. BSD & embedded) don't typically come with
# dircolors so we need to hardcode some terminals in here.
next reply other threads:[~2016-02-03 18:52 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-03 18:52 Mike Frysinger [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-09-30 20:14 [gentoo-commits] repo/gentoo:master commit in: app-shells/bash/files/ Sam James
2025-09-30 20:14 Sam James
2025-01-04 22:47 Conrad Kostecki
2024-12-07 12:48 Sam James
2024-12-07 12:48 Sam James
2024-12-06 23:12 Conrad Kostecki
2023-12-31 2:38 Conrad Kostecki
2023-04-26 21:08 Mike Gilbert
2023-04-25 21:30 Sam James
2023-03-04 19:29 Sven Wegener
2022-11-16 18:36 Conrad Kostecki
2022-09-11 23:13 Mike Gilbert
2021-07-10 21:16 Conrad Kostecki
2021-05-29 18:51 Lars Wendler
2020-12-01 13:16 Lars Wendler
2020-06-13 16:24 Mike Gilbert
2019-09-15 7:53 Mike Frysinger
2018-06-26 15:05 Mike Gilbert
2018-01-04 23:48 Sven Wegener
2017-10-20 7:45 Patrice Clement
2017-06-10 12:02 Jason Donenfeld
2017-06-10 3:07 Jason Donenfeld
2017-06-10 3:06 Jason Donenfeld
2016-07-16 9:54 Patrice Clement
2016-06-23 6:03 Mike Frysinger
2016-06-23 5:31 Mike Frysinger
2016-02-03 18:52 Mike Frysinger
2016-02-03 18:52 Mike Frysinger
2016-02-03 18:52 Mike Frysinger
2016-02-03 18:52 Mike Frysinger
2016-02-03 18:52 Mike Frysinger
2016-01-26 7:23 Mike Frysinger
2016-01-26 7:23 Mike Frysinger
2016-01-26 7:23 Mike Frysinger
2015-12-02 18:59 Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1454525501.a70b06857fc83ef6f85a6c06b3478c0c25ec8fda.vapier@gentoo \
--to=vapier@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox