256 color support in sh/csh colorls scripts(#429121), fixed syntax error in

csh script(#431315)
This commit is contained in:
Ondrej Vasik 2008-02-04 16:49:24 +00:00
parent 6d00d6195e
commit 6ee11ab3f6
3 changed files with 54 additions and 59 deletions

View File

@ -1,51 +1,45 @@
#! /bin/csh -f
# color-ls initialization
if ( "$LS_COLORS" != '' ) then
if ( $?LS_COLORS ) then
if ( $LS_COLORS != "" ) then
#do not override user specified LS_COLORS and use them
alias ll 'ls -l --color=tty'
alias l. 'ls -d .* --color=tty'
alias ls 'ls --color=tty'
exit
goto finish
endif
endif
alias ll 'ls -l'
alias l. 'ls -d .*'
set COLORS=/etc/DIR_COLORS
if ($?TERM) then
if ( -e "/etc/DIR_COLORS.$TERM" ) then
set COLORS="/etc/DIR_COLORS.$TERM"
endif
endif
if ( -f ~/.dircolors ) then
set COLORS=~/.dircolors
if ( -e "/etc/DIR_COLORS.256color" ) then
if ( "`infocmp $TERM | sed -n 's/.*colors#\([0-9]\+\).*/\1/p'`" == "256" ) then
set COLORS=/etc/DIR_COLORS.256color
endif
if ( -f ~/.dir_colors ) then
set COLORS=~/.dir_colors
endif
if ( -f ~/.dircolors ) set COLORS=~/.dircolors
if ( -f ~/.dir_colors ) set COLORS=~/.dir_colors
if ($?TERM) then
if ( -f ~/.dircolors."$TERM" ) then
set COLORS=~/.dircolors."$TERM"
endif
if ( -f ~/.dir_colors."$TERM" ) then
set COLORS=~/.dir_colors."$TERM"
endif
if ( -f ~/.dircolors."$TERM" ) set COLORS=~/.dircolors."$TERM"
if ( -f ~/.dir_colors."$TERM" ) set COLORS=~/.dir_colors."$TERM"
endif
if ( ! -e "$COLORS" ) then
exit
endif
if ( ! -e "$COLORS" ) exit
eval `dircolors -c $COLORS`
if ( "$LS_COLORS" == '' ) then
exit
endif
eval `dircolors -c $COLORS 2>/dev/null`
if ( "$LS_COLORS" == '' ) exit
set color_none=`sed -n '/^COLOR.*none/Ip' < $COLORS`
if ( "$color_none" == '' ) then
if ( "$color_none" != '' ) then
unset color_none
exit
endif
unset color_none
finish:
alias ll 'ls -l --color=tty'
alias l. 'ls -d .* --color=tty'
alias ls 'ls --color=tty'
endif
unset color_none

View File

@ -1,17 +1,14 @@
# color-ls initialization
if [ -n "$LS_COLORS" ]; then
#do not override user LS_COLORS but use them
alias ll='ls -l --color=tty' 2>/dev/null
alias l.='ls -d .* --color=tty' 2>/dev/null
alias ls='ls --color=tty' 2>/dev/null
return
fi
if [ -z "$LS_COLORS" ]; then
#do not override user LS_COLORS, so perform only for zero sized LS_COLORS
alias ll='ls -l' 2>/dev/null
alias l.='ls -d .*' 2>/dev/null
COLORS=/etc/DIR_COLORS
[ -e "/etc/DIR_COLORS.$TERM" ] && COLORS="/etc/DIR_COLORS.$TERM"
[ -e "/etc/DIR_COLORS.256color" ] && \
[ "`infocmp $TERM | sed -n 's/.*colors#\([0-9]\+\).*/\1/p'`" -eq 256 ] && \
COLORS="/etc/DIR_COLORS.256color"
[ -e "$HOME/.dircolors" ] && COLORS="$HOME/.dircolors"
[ -e "$HOME/.dir_colors" ] && COLORS="$HOME/.dir_colors"
[ -e "$HOME/.dircolors.$TERM" ] && COLORS="$HOME/.dircolors.$TERM"
@ -20,9 +17,9 @@ COLORS=/etc/DIR_COLORS
eval `dircolors --sh "$COLORS" 2>/dev/null`
[ -z "$LS_COLORS" ] && return
egrep -qi "^COLOR.*none" $COLORS >/dev/null 2>/dev/null && return
fi
if ! egrep -qi "^COLOR.*none" $COLORS >/dev/null 2>/dev/null ; then
alias ll='ls -l --color=tty' 2>/dev/null
alias l.='ls -d .* --color=tty' 2>/dev/null
alias ls='ls --color=tty' 2>/dev/null
fi

View File

@ -1,7 +1,7 @@
Summary: The GNU core utilities: a set of tools commonly used in shell scripts
Name: coreutils
Version: 6.10
Release: 4%{?dist}
Release: 5%{?dist}
License: GPLv3+
Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/
@ -291,6 +291,10 @@ fi
/sbin/runuser
%changelog
* Mon Feb 4 2008 Ondrej Vasik <ovasik@redhat.com> - 6.10-5
- enabled 256-color support in colorls shell scripts(#429121)
- fixed syntax error in csh script(#431315)
* Thu Jan 31 2008 Ondrej Vasik <ovasik@redhat.com> - 6.10-4
- forgotten return in colorls.sh change