handle situation with ro /tmp in colorls scripts (#1149761)

This commit is contained in:
Ondřej Vašík 2014-10-15 09:43:08 +02:00
parent cae27396ec
commit 2f8deb0379
3 changed files with 24 additions and 8 deletions

View File

@ -34,7 +34,14 @@ set INCLUDE="`cat "$COLORS" | grep '^INCLUDE' | cut -d ' ' -f2-`"
if ( ! -e "$COLORS" ) exit if ( ! -e "$COLORS" ) exit
set _tmp="`mktemp .colorlsXXX --tmpdir=/tmp`" set _tmp="`mktemp .colorlsXXX -q --tmpdir=/tmp`"
#if mktemp fails, exit when include was active, otherwise use $COLORS file
if ( "$_tmp" == '' ) then
if ( "$INCLUDE" == '' ) then
eval "`dircolors -c $COLORS`"
endif
goto cleanup
endif
if ( "$INCLUDE" != '' ) cat "$INCLUDE" >> $_tmp if ( "$INCLUDE" != '' ) cat "$INCLUDE" >> $_tmp
grep -v '^INCLUDE' "$COLORS" >> $_tmp grep -v '^INCLUDE' "$COLORS" >> $_tmp
@ -44,6 +51,7 @@ eval "`dircolors -c $_tmp`"
rm -f $_tmp rm -f $_tmp
if ( "$LS_COLORS" == '' ) exit if ( "$LS_COLORS" == '' ) exit
cleanup:
set color_none=`sed -n '/^COLOR.*none/Ip' < $COLORS` set color_none=`sed -n '/^COLOR.*none/Ip' < $COLORS`
if ( "$color_none" != '' ) then if ( "$color_none" != '' ) then
unset color_none unset color_none

View File

@ -32,14 +32,19 @@ if [ -z "$USER_LS_COLORS" ]; then
# Existence of $COLORS already checked above. # Existence of $COLORS already checked above.
[ -n "$COLORS" ] || return [ -n "$COLORS" ] || return
TMP="`mktemp .colorlsXXX --tmpdir=/tmp`" if [ -e "$INCLUDE" ];
then
TMP="`mktemp .colorlsXXX -q --tmpdir=/tmp`"
[ -z "$TMP" ] && return
[ -e "$INCLUDE" ] && cat "$INCLUDE" >> $TMP cat "$INCLUDE" >> $TMP
grep -v '^INCLUDE' "$COLORS" >> $TMP grep -v '^INCLUDE' "$COLORS" >> $TMP
eval "`dircolors --sh $TMP 2>/dev/null`" eval "`dircolors --sh $TMP 2>/dev/null`"
rm -f $TMP
rm -f $TMP else
eval "`dircolors --sh $COLORS 2>/dev/null`"
fi
[ -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

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.23 Version: 8.23
Release: 4%{?dist} Release: 5%{?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/
@ -372,6 +372,9 @@ fi
%{_sbindir}/chroot %{_sbindir}/chroot
%changelog %changelog
* Wed Oct 15 2014 Ondrej Vasik <ovasik@redhat.com> - 8.23-5
- handle situation with ro /tmp in colorls scripts (#1149761)
* Wed Oct 01 2014 Ondrej Vasik <ovasik@redhat.com> - 8.23-4 * Wed Oct 01 2014 Ondrej Vasik <ovasik@redhat.com> - 8.23-4
- fix the sorting in multibyte locales (NUL-terminate sort keys) - fix the sorting in multibyte locales (NUL-terminate sort keys)
- patch by Andreas Schwab (#1146185) - patch by Andreas Schwab (#1146185)