From 0b74fcfadf47699b45040120e2e99cef4a6659d1 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 9 Oct 2021 21:54:56 -0700 Subject: [PATCH] uninstall: `shellcheck` && `shfmt` --- clean_files.txt | 1 + uninstall.sh | 39 +++++++++++++++++++-------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/clean_files.txt b/clean_files.txt index d186ad30..f1736251 100644 --- a/clean_files.txt +++ b/clean_files.txt @@ -27,6 +27,7 @@ bash_it.sh clean_files.txt install.sh lint_clean_files.sh +uninstall.sh # aliases # diff --git a/uninstall.sh b/uninstall.sh index 17712610..1347fb40 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,31 +1,30 @@ #!/usr/bin/env bash -if [ -z "$BASH_IT" ]; -then - BASH_IT="$HOME/.bash_it" -fi +: "${BASH_IT:=$HOME/.bash_it}" case $OSTYPE in - darwin*) - CONFIG_FILE=.bash_profile - ;; - *) - CONFIG_FILE=.bashrc - ;; + darwin*) + CONFIG_FILE=.bash_profile + ;; + *) + CONFIG_FILE=.bashrc + ;; esac BACKUP_FILE=$CONFIG_FILE.bak -if [ ! -e "$HOME/$BACKUP_FILE" ]; then - echo -e "\033[0;33mBackup file $HOME/$BACKUP_FILE not found.\033[0m" >&2 +if [[ ! -e "$HOME/$BACKUP_FILE" ]]; then + echo -e "\033[0;33mBackup file $HOME/$BACKUP_FILE not found.\033[0m" >&2 - test -w "$HOME/$CONFIG_FILE" && - mv "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.uninstall" && - echo -e "\033[0;32mMoved your $HOME/$CONFIG_FILE to $HOME/$CONFIG_FILE.uninstall.\033[0m" -else - test -w "$HOME/$BACKUP_FILE" && - cp -a "$HOME/$BACKUP_FILE" "$HOME/$CONFIG_FILE" && - rm "$HOME/$BACKUP_FILE" && - echo -e "\033[0;32mYour original $CONFIG_FILE has been restored.\033[0m" + if [[ -w "$HOME/$CONFIG_FILE" ]]; then + if mv "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.uninstall"; then + echo -e "\033[0;32mMoved your $HOME/$CONFIG_FILE to $HOME/$CONFIG_FILE.uninstall.\033[0m" + fi + fi +elif [[ -w "$HOME/$BACKUP_FILE" ]]; then + if cp -a "$HOME/$BACKUP_FILE" "$HOME/$CONFIG_FILE"; then + rm "$HOME/$BACKUP_FILE" + echo -e "\033[0;32mYour original $CONFIG_FILE has been restored.\033[0m" + fi fi echo ""