From a0e0eebc3011c180bc8e6d7ebd7a6ab29667cfbd Mon Sep 17 00:00:00 2001 From: Alex Epstein Date: Tue, 27 Jun 2017 21:53:09 -0400 Subject: [PATCH] Test if script was installed before asking to uninstall --- uninstall.sh | 79 +++++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/uninstall.sh b/uninstall.sh index 651e2da..50b2d8f 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,50 +1,59 @@ #!/bin/bash # Author: Alexander Epstein https://github.com/alexanderepstein - -echo -n "Do you wish to uninstall currency [Y/n]: " -read -r answer -if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then - cd currency || exit 1 - ./uninstall.sh || exit 1 - cd .. || exit 1 +if [[ -f /usr/local/bin/currency ]];then + echo -n "Do you wish to uninstall currency [Y/n]: " + read -r answer + if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then + cd currency || exit 1 + ./uninstall.sh || exit 1 + cd .. || exit 1 + fi + unset answer fi -unset answer -echo -n "Do you wish to uninstall stocks [Y/n]: " -read -r answer -if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then - cd stocks || exit 1 - ./uninstall.sh - cd .. || exit 1 +if [[ -f /usr/local/bin/stocks ]];then + echo -n "Do you wish to uninstall stocks [Y/n]: " + read -r answer + if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then + cd stocks || exit 1 + ./uninstall.sh + cd .. || exit 1 + fi + unset answer fi -unset answer -echo -n "Do you wish to uninstall weather [Y/n]: " -read -r answer -if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then - cd weather || exit 1 - ./uninstall.sh - cd .. || exit 1 +if [[ -f /usr/local/bin/weather ]];then + echo -n "Do you wish to uninstall weather [Y/n]: " + read -r answer + if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then + cd weather || exit 1 + ./uninstall.sh + cd .. || exit 1 + fi + unset answer fi -unset answer -echo -n "Do you wish to uninstall crypt [Y/n]: " -read -r answer -if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then - cd crypt || exit 1 - ./uninstall.sh - cd .. || exit 1 +if [[ -f /usr/local/bin/crypt ]];then + echo -n "Do you wish to uninstall crypt [Y/n]: " + read -r answer + if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then + cd crypt || exit 1 + ./uninstall.sh + cd .. || exit 1 + fi + unset answer fi -unset answer -echo -n "Do you wish to uninstall movies [Y/n]: " -read -r answer -if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then - cd movies || exit 1 - ./uninstall.sh - cd .. || exit 1 +if [[ -f /usr/local/bin/movies ]];then + echo -n "Do you wish to uninstall movies [Y/n]: " + read -r answer + if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then + cd movies || exit 1 + ./uninstall.sh + cd .. || exit 1 + fi fi