Skip to content

Commit

Permalink
fix: Prompt user before uninstalling
Browse files Browse the repository at this point in the history
  • Loading branch information
itislu committed Apr 25, 2024
1 parent e3e4119 commit 8269e3f
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions 42free.sh
Original file line number Diff line number Diff line change
Expand Up @@ -399,18 +399,23 @@ remove_alias()

uninstall()
{
pretty_print "Uninstalling 42free..."
if stderr=$(rm -f "$script_path" 2>&1); then
pretty_print "${sty_yel}Script deleted.${sty_res}"
# Check if script_dir is empty and remove it
find "$script_dir" -maxdepth 0 -type d -empty -delete 2>/dev/null
remove_alias
pretty_print "$indicator_success 42free has been uninstalled."
exit $success
if prompt_with_enter "Do you wish to uninstall 42free? [${sty_bol}y${sty_res}/${sty_bol}N${sty_res}]"; then
pretty_print "Uninstalling 42free..."
if stderr=$(rm -f "$script_path" 2>&1); then
pretty_print "${sty_yel}Script deleted.${sty_res}"
# Check if script_dir is empty and remove it
find "$script_dir" -maxdepth 0 -type d -empty -delete 2>/dev/null
remove_alias
pretty_print "$indicator_success 42free has been uninstalled."
exit $success
else
pretty_print "$indicator_error Cannot uninstall 42free."
print_stderr
exit $major_error
fi
else
pretty_print "$indicator_error Cannot uninstall 42free."
print_stderr
exit $major_error
pretty_print "Not uninstalling."
exit $success
fi
}

Expand Down

0 comments on commit 8269e3f

Please sign in to comment.