From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 5D50658973 for ; Wed, 3 Feb 2016 18:52:13 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0999B21C052; Wed, 3 Feb 2016 18:52:09 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3AF6521C052 for ; Wed, 3 Feb 2016 18:52:08 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5FDEF340976 for ; Wed, 3 Feb 2016 18:52:06 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id E0F99D00 for ; Wed, 3 Feb 2016 18:52:02 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1454525501.a70b06857fc83ef6f85a6c06b3478c0c25ec8fda.vapier@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: app-shells/bash/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: app-shells/bash/files/bashrc X-VCS-Directories: app-shells/bash/files/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: a70b06857fc83ef6f85a6c06b3478c0c25ec8fda X-VCS-Branch: master Date: Wed, 3 Feb 2016 18:52:02 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: d264de15-b41d-4e25-886f-e86b192566d3 X-Archives-Hash: 9c98b1c12d00127c069c7f875f697e3f commit: a70b06857fc83ef6f85a6c06b3478c0c25ec8fda Author: Mike Frysinger gentoo org> AuthorDate: Tue Feb 2 22:11:11 2016 +0000 Commit: Mike Frysinger gentoo 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.