You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.5 KiB

пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 11 година
пре 11 година
пре 13 година
пре 13 година
  1. #!/usr/bin/env bash
  2. set -e
  3. [ -n "$RBENV_DEBUG" ] && set -x
  4. resolve_link() {
  5. $(type -p greadlink readlink | head -1) "$1"
  6. }
  7. abs_dirname() {
  8. local cwd="$(pwd)"
  9. local path="$1"
  10. while [ -n "$path" ]; do
  11. cd "${path%/*}"
  12. local name="${path##*/}"
  13. path="$(resolve_link "$name" || true)"
  14. done
  15. pwd
  16. cd "$cwd"
  17. }
  18. if [ -z "${RBENV_ROOT}" ]; then
  19. RBENV_ROOT="${HOME}/.rbenv"
  20. else
  21. RBENV_ROOT="${RBENV_ROOT%/}"
  22. fi
  23. export RBENV_ROOT
  24. if [ -z "${RBENV_DIR}" ]; then
  25. RBENV_DIR="$(pwd)"
  26. else
  27. cd "$RBENV_DIR" 2>/dev/null || {
  28. echo "rbenv: cannot change working directory to \`$RBENV_DIR'"
  29. exit 1
  30. } >&2
  31. RBENV_DIR="$(pwd)"
  32. cd "$OLDPWD"
  33. fi
  34. export RBENV_DIR
  35. shopt -s nullglob
  36. bin_path="$(abs_dirname "$0")"
  37. for plugin_bin in "${RBENV_ROOT}/plugins/"*/bin; do
  38. bin_path="${bin_path}:${plugin_bin}"
  39. done
  40. export PATH="${bin_path}:${PATH}"
  41. hook_path="${RBENV_HOOK_PATH}:${RBENV_ROOT}/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d:/usr/lib/rbenv/hooks"
  42. for plugin_hook in "${RBENV_ROOT}/plugins/"*/etc/rbenv.d; do
  43. hook_path="${hook_path}:${plugin_hook}"
  44. done
  45. export RBENV_HOOK_PATH="$hook_path"
  46. shopt -u nullglob
  47. command="$1"
  48. case "$command" in
  49. "" | "-h" | "--help" )
  50. echo -e "$(rbenv---version)\n$(rbenv-help)" >&2
  51. ;;
  52. "-v" )
  53. exec rbenv---version
  54. ;;
  55. * )
  56. command_path="$(command -v "rbenv-$command" || true)"
  57. if [ -z "$command_path" ]; then
  58. echo "rbenv: no such command \`$command'" >&2
  59. exit 1
  60. fi
  61. shift 1
  62. exec "$command_path" "$@"
  63. ;;
  64. esac