From 149863c322caf5dcd94240f95cc0560df2c4af51 Mon Sep 17 00:00:00 2001 From: William Ting Date: Tue, 7 Feb 2012 16:02:49 -1000 Subject: [PATCH] bash uninstallation modified to detected and remove local installations --- uninstall.sh | 55 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/uninstall.sh b/uninstall.sh index b935427..3b93213 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -30,33 +30,46 @@ if [ $OS == 'Darwin' ]; then else user_home=$(getent passwd ${user} | cut -d: -f6) fi - bashrc_file=${user_home}/.bashrc +bashrc_file=${user_home}/.bashrc # Command line parsing while true; do case "$1" in - -h|--help|-\?) show_help; exit 0;; - -p|--prefix) if [ $# -gt 1 ]; then - prefix=$2; shift 2 - else - echo "--prefix or -p require an argument" 1>&2 - exit 1 - fi ;; - --) shift; break;; - -*) echo "invalid option: $1" 1>&2; show_help; exit 1;; - *) break;; + -h|--help|-\?) show_help; exit 0;; + -p|--prefix) + if [ $# -gt 1 ]; then + prefix=$2; shift 2 + else + echo "--prefix or -p require an argument" 1>&2 + exit 1 + fi + ;; + --) shift; break;; + -*) echo "invalid option: $1" 1>&2; show_help; exit 1;; + *) break;; esac done -echo -e "Uninstalling from ${prefix} ...\n" - # UNINSTALL AUTOJUMP -sudo rm -rv ${prefix}/share/autojump/ -sudo rm -v ${prefix}/bin/jumpapplet -sudo rm -v ${prefix}/bin/autojump -sudo rm -v ${prefix}/share/man/man1/autojump.1 -sudo rm -v /etc/profile.d/autojump.bash -sudo rm -v /etc/profile.d/autojump.sh +# global / custom location installations +if [ -d "${prefix}/share/autojump/" ]; then + echo -e "\nUninstalling from ${prefix} ...\n" + sudo rm -rv ${prefix}/share/autojump/ + sudo rm -v ${prefix}/bin/jumpapplet + sudo rm -v ${prefix}/bin/autojump + sudo rm -v ${prefix}/share/man/man1/autojump.1 + sudo rm -v /etc/profile.d/autojump.zsh + sudo rm -v /etc/profile.d/autojump.sh -echo -e "\nPlease remove the line from ${bashrc_file} :\n" -echo -e "\tsource /etc/profile.d/autojump.bash" + echo -e "\nPlease remove the line from ${bashrc_file} :\n" + echo -e "\tsource /etc/profile.d/autojump.bash" +fi + +# local installations +if [ -d ~/.autojump/ ]; then + echo -e "\nUninstalling from ~/.autojump/ ...\n" + rm -rv ~/.autojump/ + + echo -e "\nPlease remove the line from ${bashrc_file} :\n" + echo -e "\tsource ~/.autojump/profile.d/autojump.bash" +fi