diff setup @ 248:fbb03c862b63

Awesome merge.
author Edho Arief <edho@myconan.net>
date Tue, 08 Nov 2011 11:59:49 +0700
parents 4eeccee282b1
children c6ad8279b076
line wrap: on
line diff
--- a/setup	Tue Nov 08 11:56:49 2011 +0700
+++ b/setup	Tue Nov 08 11:59:49 2011 +0700
@@ -19,7 +19,7 @@
   case "$1" in
     uninstall|install)
       _rc "${1}" "tcsh" ".ecos_tcsh"
-      _init "${1}" '[ -r "${HOME}/.ecos_tcsh" ] && source "${HOME}/.ecos_tcsh" #ECCORE_TCSH' ".cshrc"
+      _init "${1}" 'test -r "${HOME}/.ecos_tcsh" && source "${HOME}/.ecos_tcsh" #ECCORE_TCSH' ".cshrc"
     ;;
   esac
 }
@@ -44,17 +44,22 @@
 }
 
 _rc() {
+  if test -z "${3}" || test -z "${2}" || test -z "${1}"; then
+    _echo "Invalid command."
+    return
+  fi
   _srcfile="${rcdir}/${2}"
   _dstfile="${HOME}/${3}"
   if test ! -h "${_dstfile}"; then
     if test -f "${_dstfile}"; then
       cp "${_dstfile}" "${_dstfile}.bak"
+      _echo "${_dstfile} backed up to ${_dstfile}.bak"
     elif test -d "${_dstfile}"; then
       cp -r "${_dstfile}" "${_dstfile}.bak"
+      _echo "Directory ${_dstfile} backed up to ${_dstfile}.bak"
     fi
-    _echo "${_dstfile} backed up to ${_dstfile}.bak"
   fi
-  rm -f "${_dstfile}"
+  rm -rf "${_dstfile}"
   case "${1}" in
     install)
       ln -fs "${_srcfile}" "${_dstfile}"
@@ -71,7 +76,7 @@
   _scripttmp="${HOME}/.tmp.${3}"
   _data="${2}"
   if [ -f "${_script}" ]; then
-    grep -v "${_data}" "${_script}" > "${_scripttmp}"
+    grep -v "`printf "%s\n" "${_data}" | sed 's/.*#//'`" "${_script}" > "${_scripttmp}"
     mv -f "${_scripttmp}" "${_script}"
   fi
   case "${1}" in
@@ -106,3 +111,4 @@
     _help
   ;;
 esac
+