Getting rid of cd's in uninstall and added uninstall all

This commit is contained in:
Alex Epstein 2017-08-02 13:25:34 -04:00
parent 9ad66a6ab9
commit d39e550082
2 changed files with 26 additions and 7 deletions

View File

@ -362,6 +362,11 @@ brew uninstall bash-snippets
./uninstall.sh
```
#### To uninstall all installed bash-snippets
```bash
./uninstall.sh all
```
## Donate
If this project helped you in any way and you feel like buying a broke college kid a cup of coffee

View File

@ -9,11 +9,9 @@ askUninstall()
echo -n "Do you wish to uninstall $1 [Y/n]: "
read -r answer
if [[ "$answer" == [Yy] ]]; then
cd $1 || return 1
echo -n "Removing $1: "
rm -f /usr/local/bin/$1 > /dev/null 2>&1 || { echo "Failed" ; echo "Error removing file, try running uninstall script as sudo"; exit 1; }
echo "Success"
cd .. || return 1
else
all="0"
fi
@ -21,14 +19,30 @@ askUninstall()
fi
}
removeManpage()
removeTool()
{
rm -f /usr/local/man/man1/bash-snippets.1 2>&1 || { echo "Failed" ; echo "Error removing file, try running uninstall script as sudo"; exit 1; }
if [[ -f /usr/local/bin/$1 ]]; then
echo -n "Removing $1: "
rm -f /usr/local/bin/$1 > /dev/null 2>&1 || { echo "Failed" ; echo "Error removing file, try running uninstall script as sudo"; exit 1; }
echo "Success"
fi
}
for tool in "${tools[@]}"; do
askUninstall $tool || exit 1
done
removeManpage()
{
if [ -f "/usr/local/man/man1/bash-snippets.1" ]; then rm -f "usr/local/man/man1/bash-snippets.1" || { echo "Error removing manpage, try running uninstall script as sudo"; exit 1; } ; fi
if [ -f "/usr/local/share/man/man1/bash-snippets.1" ]; then rm -f "/usr/local/share/man/man1/bash-snippets.1" || { echo "Error removing manpage, try running uninstall script as sudo"; exit 1; } ; fi
}
if [[ $1 != "all" ]];then
for tool in "${tools[@]}"; do
askUninstall $tool || exit 1
done
else
for tool in "${tools[@]}"; do
removeTool $tool || exit 1
done
fi
if [[ $all == "1" ]]; then
removeManpage || exit 1