implode 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/usr/bin/env bash
  2. # Remove binaries.
  3. __rvm_implode_binaries()
  4. {
  5. # Load inside a subshell to avoid polutting the current shells env.
  6. (
  7. source "$rvm_scripts_path/base"
  8. rvm_log "Removing rvm-shipped binaries (rvm-prompt, rvm, rvm-sudo rvm-shell and rvm-auto-ruby)"
  9. for entry in "$rvm_bin_path/"{rvm-prompt,rvm,rvmsudo,rvm-shell,rvm-auto-ruby} ; do
  10. __rvm_rm_rf "$entry"
  11. done
  12. rvm_log "Removing rvm wrappers in $rvm_bin_path"
  13. __rvm_find "$rvm_bin_path" -type l | while read symlinked_rvm_file; do
  14. if [[ "$(__rvm_readlink "$symlinked_rvm_file")" == "$rvm_wrappers_path/"* ]]; then
  15. __rvm_rm_rf "$symlinked_rvm_file"
  16. fi
  17. done
  18. unset symlinked_rvm_file
  19. )
  20. }
  21. # Implode removes the entire rvm installation under $rvm_path, including removing wrappers.
  22. __rvm_implode()
  23. {
  24. if
  25. [[ ${rvm_force_flag:-0} -gt 0 ]] ||
  26. __rvm_ask_for "Are you SURE you wish for rvm to implode?\nThis will recursively remove $rvm_path and other rvm traces?" yes
  27. then
  28. if
  29. [[ "/" == "$rvm_path" ]]
  30. then
  31. rvm_error "remove '/' ?!... Ni!"
  32. return 1
  33. elif
  34. [[ -d "$rvm_path" ]]
  35. then
  36. __rvm_implode_binaries
  37. rvm_log "Hai! Removing $rvm_path"
  38. for file in /etc/profile.d/rvm.sh $rvm_man_path/man1/rvm.1* $rvm_path/
  39. do
  40. __rvm_rm_rf $file || rvm_error "Could not remove '$file', please try removing it manually."
  41. done
  42. if
  43. [[ -e $rvm_path ]]
  44. then
  45. rvm_warn "Failed to completely remove $rvm_path -- You will have to do so manually."
  46. else
  47. rvm_log "$rvm_path has been removed."
  48. fi
  49. if
  50. [[ "$rvm_path" == "/usr/local/rvm"* && -f "/usr/local/lib/rvm" ]]
  51. then
  52. rvm_log "Removing the rvm loader at /usr/local/lib/rvm"
  53. __rvm_rm_rf /usr/local/lib/rvm
  54. fi
  55. rvm_warn "
  56. Note you may need to manually remove /etc/rvmrc and ~/.rvmrc if they exist still.
  57. Please check all .bashrc .bash_profile .profile and .zshrc for RVM source lines and delete or comment out if this was a Per-User installation.
  58. Also make sure to remove \`${rvm_group_name:-rvm}\` group if this was a system installation.
  59. Finally it might help to relogin / restart if you want to have fresh environment (like for installing RVM again).
  60. "
  61. else
  62. rvm_log "It appears that $rvm_path is already non existant."
  63. fi
  64. else
  65. rvm_log "Psychologist intervened, cancelling implosion, crisis avoided :)"
  66. return 2
  67. fi
  68. }