changeset 125:7c01fc6f7460

Better install script.
author Edho Prima Arief <edho@myconan.net>
date Wed, 26 Oct 2011 16:52:34 +0700
parents 5bafb912837e
children 9a15f3d1b5b0
files setup
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/setup	Wed Oct 26 15:22:00 2011 +0700
+++ b/setup	Wed Oct 26 16:52:34 2011 +0700
@@ -28,10 +28,13 @@
   ln -fs "${PWD}/${1}" "${HOME}/${2}"
 }
 
-uninstall_tcsh() {
-  if [ -f "${HOME}/.cshrc" ]; then
-    grep -v '#ECCORE_TCSH' "${HOME}/.cshrc" > .cleancshrc
-    mv .cleancshrc "${HOME}/.cshrc"
+uninstall_init() {
+  script="${1}"
+  scripttmp="${1}.new.tmp"
+  hashdata="${2}"
+  if [ -f "${script}" ]; then
+    grep -v "${hashdata}" "${script}" > "${scripttmp}"
+    mv "${scripttmp}" "${script}"
   fi
 }
 
@@ -42,7 +45,10 @@
       rm -f "${HOME}/${i}"
     fi
   done
-  uninstall_tcsh
+  uninstall_init "${HOME}/.cshrc" "#ECCORE_TCSH"
+  uninstall_init "${HOME}/.bashrc" "#ECCORE_BASH"
+  uninstall_init "${HOME}/.bash_profile" "#ECCORE_BASH"
+  uninstall_init "${HOME}/.zshrc" "#ECCORE_ZSH"
 }
 
 update() {