Skip to content

Commit

Permalink
Bugfix: load rvm reset where used.
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneeseguin committed Feb 28, 2011
1 parent 1d57dba commit 7cab46a
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 79 deletions.
4 changes: 2 additions & 2 deletions scripts/cli
Expand Up @@ -805,11 +805,11 @@ rvm()
__rvm_reset
;;
reboot)
source "$rvm_scripts_path/functions/reset"
source "$rvm_scripts_path/functions/cleanup"
__rvm_reboot
;;
implode|seppuku)
source "$rvm_scripts_path/functions/reset"
source "$rvm_scripts_path/functions/implode"
__rvm_implode
;;

Expand Down
2 changes: 2 additions & 0 deletions scripts/functions/cleanup
Expand Up @@ -43,6 +43,8 @@ __rvm_reboot()
if [[ "yes" = "$response" ]] ; then
builtin cd $rvm_path

command -v __rvm_reset >> /dev/null 2>&1 || \
source "$rvm_scripts_path/functions/reset"
__rvm_reset

mv "$rvm_archives_path" "$HOME/.archives"
Expand Down
79 changes: 79 additions & 0 deletions scripts/functions/implode
@@ -0,0 +1,79 @@
#!/usr/bin/env bash

# Remove binaries.
__rvm_implode_binaries()
{
# Load inside a subshell to avoid polutting the current shells env.
(
source "$rvm_scripts_path/base"

rvm_log "Removing rvm-shipped binaries (rvm-prompt, rvm, rvm-sudom rvm-shell and rvm-auto-ruby)"
for entry in "$rvm_bin_path/"{rvm-prompt,rvm,rvmsudo,rvm-shell,rvm-auto-ruby} ; do
__rvm_rm_rf "$entry"
done

rvm_log "Removing rvm wrappers in $rvm_bin_path"
\find "$rvm_bin_path" -type l | while read symlinked_rvm_file; do
if [[ "$(readlink "$symlinked_rvm_file")" = "$rvm_wrappers_path/"* ]]; then
__rvm_rm_rf "$symlinked_rvm_file"
fi
done
unset symlinked_rvm_file
)
}

# Implode removes the entire rvm installation under $rvm_path, including removing wrappers.
__rvm_implode()
{
while : ; do

rvm_warn "Are you SURE you wish for rvm to implode?\
\nThis will recursively remove $rvm_path and other rvm traces?\
\n(type 'yes' or 'no')> "

read response

if [[ "yes" = "$response" ]] ; then

if [[ "/" = "$rvm_path" ]] ; then

rvm_error "remove '/' ?!... Ni!"

else

if [[ -d "$rvm_path" ]] ; then

__rvm_implode_binaries


rvm_log "Hai! Removing $rvm_path"

__rvm_rm_rf "$rvm_path/"

echo "$rvm_path has been removed."

if [[ "$rvm_path" = "/usr/local/rvm"* && -f "/usr/local/lib/rvm" ]]; then
rvm_log "Removing the rvm loader at /usr/local/lib/rvm"
fi

printf "rvm has been fully removed. Note you may need to manually remove /etc/rvmrc and ~/.rvmrc if they exist still."

else

rvm_log "It appears that $rvm_path is already non existant."

fi
fi
break

elif [[ "no" = "$response" ]] ; then

rvm_log "Psycologist intervened, cancelling implosion, crisis avoided :)"
break

fi
done

return 0
}

77 changes: 0 additions & 77 deletions scripts/functions/reset
Expand Up @@ -68,80 +68,3 @@ __rvm_reset()
return 0
}

# Remove binaries.
__rvm_implode_binaries()
{
# Load inside a subshell to avoid polutting the current shells env.
(
source "$rvm_scripts_path/base"

rvm_log "Removing rvm-shipped binaries (rvm-prompt, rvm, rvm-sudom rvm-shell and rvm-auto-ruby)"
for entry in "$rvm_bin_path/"{rvm-prompt,rvm,rvmsudo,rvm-shell,rvm-auto-ruby} ; do
__rvm_rm_rf "$entry"
done

rvm_log "Removing rvm wrappers in $rvm_bin_path"
\find "$rvm_bin_path" -type l | while read symlinked_rvm_file; do
if [[ "$(readlink "$symlinked_rvm_file")" = "$rvm_wrappers_path/"* ]]; then
__rvm_rm_rf "$symlinked_rvm_file"
fi
done
unset symlinked_rvm_file
)
}

# Implode removes the entire rvm installation under $rvm_path, including removing wrappers.
__rvm_implode()
{
while : ; do

rvm_warn "Are you SURE you wish for rvm to implode?\
\nThis will recursively remove $rvm_path and other rvm traces?\
\n(type 'yes' or 'no')> "

read response

if [[ "yes" = "$response" ]] ; then

if [[ "/" = "$rvm_path" ]] ; then

rvm_error "remove '/' ?!... Ni!"

else

if [[ -d "$rvm_path" ]] ; then

__rvm_implode_binaries


rvm_log "Hai! Removing $rvm_path"

__rvm_rm_rf "$rvm_path/"

echo "$rvm_path has been removed."

if [[ "$rvm_path" = "/usr/local/rvm"* && -f "/usr/local/lib/rvm" ]]; then
rvm_log "Removing the rvm loader at /usr/local/lib/rvm"
fi

printf "rvm has been fully removed. Note you may need to manually remove /etc/rvmrc and ~/.rvmrc if they exist still."

else

rvm_log "It appears that $rvm_path is already non existant."

fi
fi
break

elif [[ "no" = "$response" ]] ; then

rvm_log "Psycologist intervened, cancelling implosion, crisis avoided :)"
break

fi
done

return 0
}

3 changes: 3 additions & 0 deletions scripts/selector
Expand Up @@ -447,6 +447,9 @@ __rvm_use()

if [[ ${rvm_default_flag:-0} -eq 1 ]] ; then

command -v __rvm_reset >> /dev/null 2>&1 || \
source "$rvm_scripts_path/functions/reset"

__rvm_reset

fi
Expand Down

0 comments on commit 7cab46a

Please sign in to comment.