diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh index d7872b3..6a02d4c 100644 --- a/scripts/uninstall.sh +++ b/scripts/uninstall.sh @@ -15,6 +15,18 @@ print_success() { echo -e "\033[1;32m[SUCCESS]\033[0m $1"; } print_warning() { echo -e "\033[1;33m[WARNING]\033[0m $1"; } print_error() { echo -e "\033[1;31m[ERROR]\033[0m $1"; } +# Remove any stale 'seedpass' executables that may still be on the PATH. +remove_stale_executables() { + IFS=':' read -ra DIRS <<< "$PATH" + for dir in "${DIRS[@]}"; do + candidate="$dir/seedpass" + if [ -f "$candidate" ] && [ "$candidate" != "$LAUNCHER_PATH" ]; then + print_info "Removing old executable '$candidate'..." + rm -f "$candidate" || true + fi + done +} + main() { if [ -d "$INSTALL_DIR" ]; then print_info "Removing installation directory '$INSTALL_DIR'..." @@ -23,6 +35,7 @@ main() { print_info "Installation directory not found." fi + if [ -f "$LAUNCHER_PATH" ]; then print_info "Removing launcher script '$LAUNCHER_PATH'..." rm -f "$LAUNCHER_PATH" @@ -30,11 +43,16 @@ main() { print_info "Launcher script not found." fi + remove_stale_executables + print_info "Attempting to uninstall any global 'seedpass' package with pip..." - if command -v pip &> /dev/null; then + if command -v python3 &> /dev/null; then + python3 -m pip uninstall -y seedpass >/dev/null 2>&1 || true + elif command -v pip &> /dev/null; then pip uninstall -y seedpass >/dev/null 2>&1 || true - elif command -v pip3 &> /dev/null; then - pip3 uninstall -y seedpass >/dev/null 2>&1 || true + fi + if command -v pipx &> /dev/null; then + pipx uninstall -y seedpass >/dev/null 2>&1 || true fi print_success "SeedPass uninstalled."