comparison rc/bashrc @ 365:3e62b13e1f48

Better test for rm aliasing Check for GNU rm availability and whether the rm (GNU or not) has -I parameter.
author Edho Arief <edho@myconan.net>
date Mon, 04 Jun 2012 15:41:48 +0700
parents 59dc2f13e0ae
children f615b9564fce
comparison
equal deleted inserted replaced
364:7833673f4860 365:3e62b13e1f48
32 export LS_COLORS= 32 export LS_COLORS=
33 export BLOCKSIZE=1K 33 export BLOCKSIZE=1K
34 export BLOCK_SIZE=si 34 export BLOCK_SIZE=si
35 35
36 alias ls="ls -F" 36 alias ls="ls -F"
37 alias rm="rm -i"
38 alias rd="rdesktop -g 1280x600 -K -a 15 -x m -z -P -r sound:off -r clipboard:CLIPBOARD -5" 37 alias rd="rdesktop -g 1280x600 -K -a 15 -x m -z -P -r sound:off -r clipboard:CLIPBOARD -5"
39 alias man="LANG=C man" 38 alias man="LANG=C man"
40 39
41 _has_gnu_ls= 40 _has_gnu_ls=
42 _has_gnu_grep= 41 _has_gnu_grep=
193 if command -v less > /dev/null 2>&1; then 192 if command -v less > /dev/null 2>&1; then
194 alias less="less -Rins" 193 alias less="less -Rins"
195 export PAGER="less -Rins" 194 export PAGER="less -Rins"
196 fi 195 fi
197 196
198 rm -If "/tmp/.nonexistent.$(date '+%Y%m%d%H%M%S')" 2> /dev/null && alias rm="rm -I" 197 # Test if we have GNU rm prefixed by g (esp if on non-GNU system).
198 # Usually on old Solaris and {Net,Open,DragonFly}BSD.
199 if command -v grm > /dev/null 2>&1; then
200 _rm="grm"
201 else
202 _rm="rm"
203 fi
204 # Test if the specified rm has "-I" parameter since it's much better.
205 if "${_rm}" -If "/tmp/.nonexistent.$(date '+%Y%m%d%H%M%S')" 2> /dev/null; then
206 alias rm="${_rm} -I"
207 else
208 alias rm="${_rm} -i"
209 fi
199 210
200 [ -f "${HOME}/.ecos_bash.after" ] && . "${HOME}/.ecos_bash.after" 211 [ -f "${HOME}/.ecos_bash.after" ] && . "${HOME}/.ecos_bash.after"