rvm-auto-ruby 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/env bash
  2. export HOME="${HOME%%+(\/)}" # Remove trailing slashes if they exist on HOME
  3. if (( ${rvm_ignore_rvmrc:=0} == 0 ))
  4. then
  5. for rvmrc in /etc/rvmrc "$HOME/.rvmrc"
  6. do
  7. if [[ -f "$rvmrc" ]]
  8. then
  9. if GREP_OPTIONS="" \grep '^\s*rvm .*$' "$rvmrc" >/dev/null 2>&1
  10. then
  11. printf "%b" "\nError: $rvmrc is for rvm settings only.\nrvm CLI may NOT be called from within $rvmrc. \nSkipping the loading of $rvmrc"
  12. return 1
  13. else
  14. source "$rvmrc"
  15. fi
  16. fi
  17. done
  18. fi
  19. # duplication marker jdgkjnfnkjdngjkfnd4fd
  20. export rvm_path
  21. if [[ -z "${rvm_path:-}" ]]
  22. then
  23. if [[ -d "${0%/bin/rvm-auto-ruby}" ]]
  24. then rvm_path="$( \cd "${0%/bin/rvm-auto-ruby}">/dev/null; pwd )"
  25. elif (( UID == 0 )) && [[ -d "/usr/local/rvm" ]]
  26. then rvm_path="/usr/local/rvm"
  27. elif [[ -d "${HOME}/.rvm" ]]
  28. then rvm_path="${HOME}/.rvm"
  29. elif [[ -d "/usr/local/rvm" ]]
  30. then rvm_path="/usr/local/rvm"
  31. else echo "Can't find rvm install!" 1>&2 ; exit 1
  32. fi
  33. fi
  34. true ${rvm_scripts_path:="$rvm_path/scripts"}
  35. true ${rvm_environments_path:="$rvm_path/environments"}
  36. if [[ -n "$rvm_path" && -s "$rvm_scripts_path/rvm" ]]
  37. then source "$rvm_scripts_path/rvm" > /dev/null 2>&1
  38. elif [[ -s "$HOME/.rvm/scripts/rvm" ]]
  39. then source "$HOME/.rvm/scripts/rvm" > /dev/null 2>&1
  40. elif [[ -s "/usr/local/rvm/scripts/rvm" ]]
  41. then source "/usr/local/rvm/scripts/rvm" > /dev/null 2>&1
  42. else
  43. echo "Unable to detect rvm, please manually set the rvm_path env variable." >&2
  44. exit 1
  45. fi
  46. typeset -f rvm >/dev/null 2>&1 || {
  47. echo "RVM not loaded, aborting." >&2
  48. exit 1
  49. }
  50. case $0 in
  51. (*rvm-shebang-ruby)
  52. rvm_promptless=1 rvm rvmrc load "$(dirname "$(which "$1")")" > /dev/null 2>&1
  53. ;;
  54. (*)
  55. rvm_promptless=1 rvm rvmrc load > /dev/null 2>&1
  56. ;;
  57. esac
  58. exec ruby "$@"