reset 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/usr/bin/env bash
  2. # Reset any rvm gathered information about the system and its state.
  3. # rvm will refresh the stored information the next time it is called after reset.
  4. __rvm_reset()
  5. {
  6. \typeset flag flags file files config configs variable
  7. __rvm_remove_rvm_from_path ; __rvm_conditionally_add_bin_path
  8. export PATH
  9. builtin hash -r
  10. flags=( default passenger editor )
  11. for flag in "${flags[@]}"; do
  12. \command \rm -f "${rvm_bin_path}"/${flag}_*
  13. done
  14. for file in system default ; do
  15. if [[ -f "$rvm_path/${file}" ]] ; then
  16. \command \rm -f "$rvm_path/${file}"
  17. fi
  18. if [[ -f "$rvm_path/config/${file}" ]] ; then
  19. \command \rm -f "$rvm_path/config/${file}"
  20. fi
  21. if [[ -f "$rvm_environments_path/${file}" ]] ; then
  22. \command \rm -f "$rvm_environments_path/${file}"
  23. fi
  24. done
  25. # Go back to a clean state.
  26. __rvm_use_system
  27. __rvm_unset_ruby_variables
  28. __rvm_unset_exports
  29. configs=(system_ruby system_gem_path system_user_gem_path)
  30. for system_config in "${configs[@]}"
  31. do
  32. __rvm_db_ "$rvm_user_path/db" "$system_config" "delete"
  33. done
  34. files=(ruby gem rake irb $(__rvm_cd "${rvm_bin_path}" ; \
  35. __rvm_find . -mindepth 1 -maxdepth 1 -iname 'default*' -type f \
  36. | __rvm_sed -e 's#./##g'))
  37. for file in "${files[@]}"; do
  38. if [[ -f "${rvm_bin_path}/$file" ]] ; then
  39. \command \rm -f "${rvm_bin_path}/$file"
  40. fi
  41. done
  42. return 0
  43. }