diff --git a/bin/gvm b/bin/gvm index f55682a..9957ea8 100755 --- a/bin/gvm +++ b/bin/gvm @@ -15,7 +15,7 @@ fi command=$1 if [[ $command == "implode" ]]; then - rm -rf "$GVM_ROOT" + gvm_implode exit 0 fi diff --git a/scripts/env/gvm b/scripts/env/gvm index 0a6702f..879d119 100644 --- a/scripts/env/gvm +++ b/scripts/env/gvm @@ -26,7 +26,8 @@ function gvm() { shift gvm_use "$@" elif [[ "$1" == "implode" ]]; then - rm -rf "$GVM_ROOT" + . "$GVM_ROOT/scripts/env/implode" + gvm_implode elif [[ "$1" == "pkgset" ]] && [[ "$2" == "use" ]]; then . "$GVM_ROOT/scripts/env/pkgset-use" shift diff --git a/scripts/env/implode b/scripts/env/implode new file mode 100644 index 0000000..1125157 --- /dev/null +++ b/scripts/env/implode @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +function gvm_implode() { + read -p "Are you sure? [Y/n] " -n 1 -r + echo + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + display_message "Action cancelled" + else + (rm -rf "$GVM_ROOT" && display_message "GVM successfully removed") || display_error "Failed to uninstall gvm" + fi +} diff --git a/scripts/install b/scripts/install index a9cc18e..5bf54ef 100755 --- a/scripts/install +++ b/scripts/install @@ -95,6 +95,7 @@ create_enviroment() { echo "export DYLD_LIBRARY_PATH; DYLD_LIBRARY_PATH=\"\${GVM_OVERLAY_PREFIX}/lib:\${DYLD_LIBRARY_PATH}\"" >> "$new_env_file" echo "export PKG_CONFIG_PATH; PKG_CONFIG_PATH=\"\${GVM_OVERLAY_PREFIX}/lib/pkgconfig:\${PKG_CONFIG_PATH}\"" >> "$new_env_file" . "$GVM_ROOT/scripts/env/use" + . "$GVM_ROOT/scripts/env/implode" gvm_use "$GO_NAME" &> /dev/null || display_fatal "Failed to use installed version" gvm pkgset create global diff --git a/tests/zzgvm_implode_comment_test.sh b/tests/zzgvm_implode_comment_test.sh new file mode 100644 index 0000000..6324ccf --- /dev/null +++ b/tests/zzgvm_implode_comment_test.sh @@ -0,0 +1,3 @@ +source $GVM_ROOT/scripts/gvm +yes n | gvm implode # status=0; match=/Action cancelled/ +yes | gvm implode # status=0; match=/GVM successfully removed/