add support for INCLUDE in colorls scripts (#818069)

This commit is contained in:
Ondrej Oprala 2013-03-11 16:00:59 +01:00
parent 76ade64f4b
commit 1ad51b6276
3 changed files with 22 additions and 4 deletions

View File

@ -10,6 +10,8 @@ endif
alias ll 'ls -l' alias ll 'ls -l'
alias l. 'ls -d .*' alias l. 'ls -d .*'
set COLORS=/etc/DIR_COLORS set COLORS=/etc/DIR_COLORS
set TMP="`mktemp .colorlsXXX`"
if ($?TERM) then if ($?TERM) then
if ( -e "/etc/DIR_COLORS.$TERM" ) then if ( -e "/etc/DIR_COLORS.$TERM" ) then
set COLORS="/etc/DIR_COLORS.$TERM" set COLORS="/etc/DIR_COLORS.$TERM"
@ -26,10 +28,14 @@ if ($?TERM) then
if ( -f ~/.dircolors."$TERM" ) set COLORS=~/.dircolors."$TERM" if ( -f ~/.dircolors."$TERM" ) set COLORS=~/.dircolors."$TERM"
if ( -f ~/.dir_colors."$TERM" ) set COLORS=~/.dir_colors."$TERM" if ( -f ~/.dir_colors."$TERM" ) set COLORS=~/.dir_colors."$TERM"
endif endif
set INCLUDE="`cat "$COLORS" | grep '^INCLUDE' | cut -d ' ' -f2-`"
if ( ! -e "$COLORS" ) exit if ( ! -e "$COLORS" ) exit
eval "`dircolors -c $COLORS`" if ( "$INCLUDE" != '' ) cat "$INCLUDE" > $TMP
cat "$COLORS" | grep -v '^INCLUDE' >> $TMP
eval "`dircolors -c $TMP`"
if ( "$LS_COLORS" == '' ) exit if ( "$LS_COLORS" == '' ) exit
set color_none=`sed -n '/^COLOR.*none/Ip' < $COLORS` set color_none=`sed -n '/^COLOR.*none/Ip' < $COLORS`
@ -38,6 +44,7 @@ if ( "$color_none" != '' ) then
exit exit
endif endif
unset color_none unset color_none
rm -f $TMP
finish: finish:
alias ll 'ls -l --color=auto' alias ll 'ls -l --color=auto'

View File

@ -10,11 +10,15 @@ if [ -z "$USER_LS_COLORS" ]; then
# Skip the rest for noninteractive shells. # Skip the rest for noninteractive shells.
[ -z "$PS1" ] && return [ -z "$PS1" ] && return
INCLUDE=
COLORS= COLORS=
TMP="`mktemp .colorlsXXX`"
for colors in "$HOME/.dir_colors.$TERM" "$HOME/.dircolors.$TERM" \ for colors in "$HOME/.dir_colors.$TERM" "$HOME/.dircolors.$TERM" \
"$HOME/.dir_colors" "$HOME/.dircolors"; do "$HOME/.dir_colors" "$HOME/.dircolors"; do
[ -e "$colors" ] && COLORS="$colors" && break [ -e "$colors" ] && COLORS="$colors" && \
INCLUDE="`cat "$COLORS" | grep '^INCLUDE' | cut -d ' ' -f2-`" && \
break
done done
[ -z "$COLORS" ] && [ -e "/etc/DIR_COLORS.256color" ] && \ [ -z "$COLORS" ] && [ -e "/etc/DIR_COLORS.256color" ] && \
@ -30,9 +34,13 @@ if [ -z "$USER_LS_COLORS" ]; then
# Existence of $COLORS already checked above. # Existence of $COLORS already checked above.
[ -n "$COLORS" ] || return [ -n "$COLORS" ] || return
eval "`dircolors --sh "$COLORS" 2>/dev/null`" [ -e "$INCLUDE" ] && cat "$INCLUDE" > $TMP
cat "$COLORS" | grep -v '^INCLUDE' >> $TMP
eval "`dircolors --sh $TMP 2>/dev/null`"
[ -z "$LS_COLORS" ] && return [ -z "$LS_COLORS" ] && return
grep -qi "^COLOR.*none" $COLORS >/dev/null 2>/dev/null && return grep -qi "^COLOR.*none" $COLORS >/dev/null 2>/dev/null && return
rm -f $TMP
fi fi
alias ll='ls -l --color=auto' 2>/dev/null alias ll='ls -l --color=auto' 2>/dev/null

View File

@ -1,7 +1,7 @@
Summary: A set of basic GNU tools commonly used in shell scripts Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils Name: coreutils
Version: 8.21 Version: 8.21
Release: 8%{?dist} Release: 9%{?dist}
License: GPLv3+ License: GPLv3+
Group: System Environment/Base Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/ Url: http://www.gnu.org/software/coreutils/
@ -375,6 +375,9 @@ fi
%{_sbindir}/chroot %{_sbindir}/chroot
%changelog %changelog
* Mon Mar 11 2013 Ondrej Oprala <ooprala@redhat.com> 8.21-9
- add support for INCLUDE in colorls scripts (#818069)
* Mon Mar 04 2013 Ondrej Vasik <ovasik@redhat.com> 8.21-8 * Mon Mar 04 2013 Ondrej Vasik <ovasik@redhat.com> 8.21-8
- fix factor on AArch64 (M.Salter, #917735) - fix factor on AArch64 (M.Salter, #917735)