colorls profile script tmp file handling improvements

This commit is contained in:
Ville Skyttä 2013-05-08 17:25:06 +02:00 committed by Ondřej Vašík
parent 7bbf86f2fe
commit f0b6f85aff
3 changed files with 15 additions and 7 deletions

View File

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

View File

@ -12,7 +12,6 @@ if [ -z "$USER_LS_COLORS" ]; then
INCLUDE=
COLORS=
TMP="`mktemp .colorlsXXX --tmpdir=/tmp`"
for colors in "$HOME/.dir_colors.$TERM" "$HOME/.dircolors.$TERM" \
"$HOME/.dir_colors" "$HOME/.dircolors"; do
@ -34,13 +33,17 @@ if [ -z "$USER_LS_COLORS" ]; then
# Existence of $COLORS already checked above.
[ -n "$COLORS" ] || return
TMP="`mktemp .colorlsXXX --tmpdir=/tmp`"
[ -e "$INCLUDE" ] && cat "$INCLUDE" > $TMP
cat "$COLORS" | grep -v '^INCLUDE' >> $TMP
grep -v '^INCLUDE' "$COLORS" >> $TMP
eval "`dircolors --sh $TMP 2>/dev/null`"
rm -f $TMP
[ -z "$LS_COLORS" ] && return
grep -qi "^COLOR.*none" $COLORS >/dev/null 2>/dev/null && return
rm -f $TMP
fi
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
Name: coreutils
Version: 8.21
Release: 11%{?dist}
Release: 12%{?dist}
License: GPLv3+
Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/
@ -375,6 +375,9 @@ fi
%{_sbindir}/chroot
%changelog
* Wed May 08 2013 Ondrej Vasik <ovasik@redhat.com 8.21-12
- optimization of colorls scripts by Ville Skytta (#961012)
* Fri Apr 05 2013 Ondrej Oprala <ooprala@redhat.com 8.21-11
- Fix tmp file location in colorls scripts (#948008)