rvm 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/env bash
  2. if (( ${rvm_ignore_rvmrc:=0} == 0 ))
  3. then
  4. declare rvmrc
  5. rvm_rvmrc_files=("/etc/rvmrc" "$HOME/.rvmrc")
  6. if [[ -n "${rvm_prefix:-}" ]] && ! [[ "$HOME/.rvmrc" -ef "${rvm_prefix}/.rvmrc" ]]
  7. then rvm_rvmrc_files+=( "${rvm_prefix}/.rvmrc" )
  8. fi
  9. for rvmrc in "${rvm_rvmrc_files[@]}"
  10. do
  11. if [[ -f "$rvmrc" ]]
  12. then
  13. if GREP_OPTIONS="" \grep '^\s*rvm .*$' "$rvmrc" >/dev/null 2>&1
  14. then
  15. printf "%b" "
  16. Error:
  17. $rvmrc is for rvm settings only.
  18. rvm CLI may NOT be called from within $rvmrc.
  19. Skipping the loading of $rvmrc
  20. "
  21. exit 1
  22. else
  23. source "$rvmrc"
  24. fi
  25. fi
  26. done
  27. unset rvm_rvmrc_files
  28. unset rvmrc
  29. fi
  30. # duplication marker jdgkjnfnkjdngjkfnd4fd
  31. export rvm_path
  32. if [[ -z "${rvm_path:-}" ]]
  33. then
  34. if [[ -d "${0%/bin/rvm}" ]]
  35. then rvm_path="$( \cd "${0%/bin/rvm}">/dev/null; pwd )"
  36. elif (( UID == 0 )) && [[ -d "/usr/local/rvm" ]]
  37. then rvm_path="/usr/local/rvm"
  38. elif [[ -d "${HOME}/.rvm" ]]
  39. then rvm_path="${HOME}/.rvm"
  40. elif [[ -d "/usr/local/rvm" ]]
  41. then rvm_path="/usr/local/rvm"
  42. else echo "Can't find rvm install!" 1>&2 ; exit 1
  43. fi
  44. fi
  45. # allow disabling check temporary
  46. : rvm_is_not_a_shell_function:${rvm_is_not_a_shell_function:=1}
  47. export rvm_is_not_a_shell_function
  48. # if to prevent fork-bomb
  49. if source "${rvm_scripts_path:="$rvm_path/scripts"}/rvm"
  50. then
  51. typeset -f rvm >/dev/null 2>&1 || {
  52. echo "RVM not loaded, aborting." >&2
  53. exit 1
  54. }
  55. rvm "$@"
  56. else
  57. echo "Error sourcing RVM!" 1>&2
  58. exit 1
  59. fi