changeset 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 7833673f4860
children f615b9564fce
files rc/bashrc
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/rc/bashrc	Sat Jun 02 17:07:57 2012 +0700
+++ b/rc/bashrc	Mon Jun 04 15:41:48 2012 +0700
@@ -34,7 +34,6 @@
 export BLOCK_SIZE=si
 
 alias ls="ls -F"
-alias rm="rm -i"
 alias rd="rdesktop -g 1280x600 -K -a 15 -x m -z -P -r sound:off -r clipboard:CLIPBOARD -5"
 alias man="LANG=C man"
 
@@ -195,6 +194,18 @@
   export PAGER="less -Rins"
 fi
 
-rm -If "/tmp/.nonexistent.$(date '+%Y%m%d%H%M%S')" 2> /dev/null && alias rm="rm -I"
+# Test if we have GNU rm prefixed by g (esp if on non-GNU system).
+# Usually on old Solaris and {Net,Open,DragonFly}BSD.
+if command -v grm > /dev/null 2>&1; then
+  _rm="grm"
+else
+  _rm="rm"
+fi
+# Test if the specified rm has "-I" parameter since it's much better.
+if "${_rm}" -If "/tmp/.nonexistent.$(date '+%Y%m%d%H%M%S')" 2> /dev/null; then
+  alias rm="${_rm} -I"
+else
+  alias rm="${_rm} -i"
+fi
 
 [ -f "${HOME}/.ecos_bash.after" ] && . "${HOME}/.ecos_bash.after"