[coreutils] colorls profile script tmp file handling improvements
Ondrej Vasik
ovasik at fedoraproject.org
Wed May 8 15:25:24 UTC 2013
commit f0b6f85aff0496c51c8fcb58197a8a132949a4e5
Author: Ville Skyttä <ville.skytta at iki.fi>
Date: Wed May 8 17:25:06 2013 +0200
colorls profile script tmp file handling improvements
coreutils-colorls.csh | 8 +++++---
coreutils-colorls.sh | 9 ++++++---
coreutils.spec | 5 ++++-
3 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/coreutils-colorls.csh b/coreutils-colorls.csh
index 5a54e45..fbe97b7 100755
--- a/coreutils-colorls.csh
+++ b/coreutils-colorls.csh
@@ -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'
diff --git a/coreutils-colorls.sh b/coreutils-colorls.sh
index 5347b2a..7d27940 100755
--- a/coreutils-colorls.sh
+++ b/coreutils-colorls.sh
@@ -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
diff --git a/coreutils.spec b/coreutils.spec
index 48b39f5..ffb5dd6 100644
--- a/coreutils.spec
+++ b/coreutils.spec
@@ -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 at redhat.com 8.21-12
+- optimization of colorls scripts by Ville Skytta (#961012)
+
* Fri Apr 05 2013 Ondrej Oprala <ooprala at redhat.com 8.21-11
- Fix tmp file location in colorls scripts (#948008)
More information about the scm-commits
mailing list