summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2016-02-02 17:08:19 -0500
committerMike Frysinger <vapier@gentoo.org>2016-02-03 13:51:41 -0500
commit747857408315deb4b6a0ddd2a34484ca8e5ec2ff (patch)
tree5248bf4331c9ec81d1791b05e88ed378efdc5cf3
parentapp-shells/bash: bashrc: quote the output of dircolors #572582#8 (diff)
downloadgentoo-747857408315deb4b6a0ddd2a34484ca8e5ec2ff.tar.gz
gentoo-747857408315deb4b6a0ddd2a34484ca8e5ec2ff.tar.bz2
gentoo-747857408315deb4b6a0ddd2a34484ca8e5ec2ff.zip
app-shells/bash: bashrc: drop custom parsing of dircolors databases #572582
Starting with coreutils-8.24, the dircolors TERM entries are run through fnmatch rather than being a plain text string. This means our parsing logic no longer works because we assumed fixed strings. It isn't easy to process a list of path globs in bash, so rework the code to always run the dircolors tool. We were doing this anyways in the majority of cases, so it's not like we're adding that much overhead. The only people who are negatively impacted are interactive colorless terminals. Reported-by: Bernd Feige <Bernd.Feige@gmx.net>
-rw-r--r--app-shells/bash/files/bashrc30
1 files changed, 11 insertions, 19 deletions
diff --git a/app-shells/bash/files/bashrc b/app-shells/bash/files/bashrc
index c5b449bf837..414f8482569 100644
--- a/app-shells/bash/files/bashrc
+++ b/app-shells/bash/files/bashrc
@@ -52,27 +52,19 @@ esac
# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS. Try to use the external file
-# first to take advantage of user additions. Use internal bash
-# globbing instead of external grep binary.
+# first to take advantage of user additions.
use_color=false
-safe_term=${TERM//[^[:alnum:]]/?} # sanitize TERM
-match_lhs=""
-[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
-[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
-[[ -z ${match_lhs} ]] \
- && type -P dircolors >/dev/null \
- && match_lhs=$(dircolors --print-database)
-[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true
-
-if ${use_color} ; then
+if type -P dircolors >/dev/null ; then
# Enable colors for ls, etc. Prefer ~/.dir_colors #64489
- if type -P dircolors >/dev/null ; then
- if [[ -f ~/.dir_colors ]] ; then
- eval "$(dircolors -b ~/.dir_colors)"
- elif [[ -f /etc/DIR_COLORS ]] ; then
- eval "$(dircolors -b /etc/DIR_COLORS)"
- fi
+ LS_COLORS=
+ if [[ -f ~/.dir_colors ]] ; then
+ eval "$(dircolors -b ~/.dir_colors)"
+ elif [[ -f /etc/DIR_COLORS ]] ; then
+ eval "$(dircolors -b /etc/DIR_COLORS)"
+ else
+ eval "$(dircolors -b)"
fi
+ [[ -n ${LS_COLORS:+set} ]] && use_color=true
else
# Some systems (e.g. BSD & embedded) don't typically come with
# dircolors so we need to hardcode some terminals in here.
@@ -107,4 +99,4 @@ for sh in /etc/bash/bashrc.d/* ; do
done
# Try to keep environment pollution down, EPA loves us.
-unset use_color safe_term match_lhs sh
+unset use_color sh