aboutsummaryrefslogtreecommitdiffstats
path: root/uninstall.sh
diff options
context:
space:
mode:
authorJesus <heckyel@hyperbola.info>2025-05-18 17:08:38 -0500
committerJesus <heckyel@hyperbola.info>2025-05-18 17:08:38 -0500
commit6fff4075d94a87997dba4539446ef696a36278cd (patch)
tree78cc4188bfc30552e1579f10f2e1fe54eb13d441 /uninstall.sh
parentcc476600113c04cc8c2480417f36c61031840e31 (diff)
downloadhyperterm-6fff4075d94a87997dba4539446ef696a36278cd.tar.lz
hyperterm-6fff4075d94a87997dba4539446ef696a36278cd.tar.xz
hyperterm-6fff4075d94a87997dba4539446ef696a36278cd.zip
update
Diffstat (limited to 'uninstall.sh')
-rw-r--r--uninstall.sh55
1 files changed, 25 insertions, 30 deletions
diff --git a/uninstall.sh b/uninstall.sh
index 2c884f4..7c963a5 100644
--- a/uninstall.sh
+++ b/uninstall.sh
@@ -39,21 +39,21 @@ function show_usage() {
"--help (-h): Display this help message"
msg "--silent (-s): Desinstala sin solicitar entrada" \
"--silent (-s): Uninstall without prompting for input"
- exit 0;
}
+# Parse long options
for param in "$@"; do
shift
case "$param" in
- "--help") set -- "$@" "-h" ;;
- "--silent") set -- "$@" "-s" ;;
- *) set -- "$@" "$param"
+ "--help") set -- "$@" "-h" ;;
+ "--silent") set -- "$@" "-s" ;;
+ *) set -- "$@" "$param"
esac
done
+# Parse short options
OPTIND=1
-while getopts "hs" opt
-do
+while getopts "hs" opt; do
case "$opt" in
"h") show_usage; exit 0 ;;
"s") silent=true ;;
@@ -62,46 +62,42 @@ do
done
shift $((OPTIND - 1))
-# Uninstall
-# ---------
+# Uninstall function
function _uninstall() {
- if [ -z "$HYPER_BASH" ];
- then
+ if [[ -z "$HYPER_BASH" ]]; then
HYPER_BASH="$HOME/.hyperterm"
fi
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
+ if [[ ! -e "$HOME/$BACKUP_FILE" ]]; then
msg_err "\033[0;33mEl archivo de respaldo $HOME/$BACKUP_FILE no fue encontrado.\033[0m" \
"\033[0;33mBackup file $HOME/$BACKUP_FILE not found.\033[0m"
- test -w "$HOME/$CONFIG_FILE" &&
- mv "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.uninstall" &&
+ if test -w "$HOME/$CONFIG_FILE"; then
+ mv "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.uninstall"
msg "\033[0;32mEl archivo $HOME/$CONFIG_FILE ha sido movido a $HOME/$CONFIG_FILE.uninstall.\033[0m" \
"\033[0;32mMoved your $HOME/$CONFIG_FILE to $HOME/$CONFIG_FILE.uninstall.\033[0m"
+ fi
else
- test -w "$HOME/$BACKUP_FILE" &&
- cp -a "$HOME/$BACKUP_FILE" "$HOME/$CONFIG_FILE" &&
- rm "$HOME/$BACKUP_FILE" &&
+ if test -w "$HOME/$BACKUP_FILE"; then
+ cp -a "$HOME/$BACKUP_FILE" "$HOME/$CONFIG_FILE"
+ rm "$HOME/$BACKUP_FILE"
msg "\033[0;32mTu archivo original $CONFIG_FILE ha sido restaurado.\033[0m" \
"\033[0;32mYour original $CONFIG_FILE has been restored.\033[0m"
+ fi
fi
- if [[ -d $HOME/.hyperterm ]]; then
+ if [[ -d "$HOME/.hyperterm" ]]; then
rm -fr "$HOME/.hyperterm"
fi
- msg "\033[1;32m==>\e[0m\033[1m Desintalación realizada con éxito! \e[m" \
+ msg "\033[1;32m==>\e[0m\033[1m Desinstalación realizada con éxito! \e[m" \
"\033[1;32m==>\e[0m\033[1m Uninstallation finished successfully! \e[m"
msg "\033[0;32mDisculpe las molestias!! \e[m" \
@@ -113,20 +109,19 @@ function _uninstall() {
msg "\033[1;36m ->\e[0m\033[1m Abra una nueva shell/tab/terminal \e[m" \
"\033[1;36m ->\e[0m\033[1m Open a new shell/tab/terminal \e[m"
}
-# -------
-if ! [[ $silent ]]; then
- while ! [ $silent ]
- do
+# Run uninstaller interactively or silently
+if [[ -z "$silent" ]]; then
+ while [[ -z "$silent" ]]; do
question=$(msg "¿Estás seguro de desinstalar HyperTerm? [s/N]: " \
"Are you sure to uninstall HyperTerm? [y/N]: ")
read -r -p "$question" input
- case $input in
+ case "$input" in
[yY]|[sS]) _uninstall "$@"; break ;;
[nN]|"") break ;;
*) msg "Por favor responde sí o no" \
- "Please answer yes or no.";;
+ "Please answer yes or no." ;;
esac
done
else