alias 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/usr/bin/env bash
  2. alias_show() {
  3. \typeset expanded_alias_name
  4. if
  5. [[ -z "${1:-$alias_name}" ]]
  6. then
  7. rvm_log "usage: 'rvm alias show [alias_name]'"
  8. return 1
  9. fi
  10. [[ -s "$rvm_path/config/alias" ]] || return 2
  11. expanded_alias_name="$( __rvm_db_ "$rvm_path/config/alias" "${1:-$alias_name}")"
  12. if
  13. [[ -z "$expanded_alias_name" ]]
  14. then
  15. rvm_error "Unknown alias name: '${1:-$alias_name}'"
  16. return 3
  17. else
  18. if [[ -n "$gemset_name" ]]
  19. then printf "%b" "${expanded_alias_name}${rvm_gemset_separator:-"@"}${gemset_name}\n"
  20. else printf "%b" "${expanded_alias_name}\n"
  21. fi
  22. fi
  23. }
  24. alias_after_delete_default()
  25. {
  26. [[ "$1" == "default" ]] || return 0
  27. for _path in "$rvm_bin_path"/default_*
  28. do
  29. # remove default_ruby
  30. if [[ -f "$_path" ]]
  31. then \command \rm -rfv "${_path}" || return $?
  32. fi
  33. # remove ruby
  34. _path="${_path#default_}"
  35. if [[ -f "$_path" ]]
  36. then \command \rm -rfv "${_path}" || return $?
  37. fi
  38. done
  39. for _path in "$rvm_path"/wrappers/default/* gem irb erb ri rdoc testrb rake ruby bundle
  40. do
  41. _path="${_path##*\/}"
  42. \command \rm -fv "$rvm_bin_path/${_path}" || return $?
  43. done
  44. }
  45. alias_delete_execute()
  46. {
  47. for _path in "$rvm_rubies_path" "$rvm_gems_path" "$rvm_environments_path" "$rvm_wrappers_path"
  48. do
  49. if [[ -L "$_path/$1" ]]
  50. then \command \rm -fv "$_path/$1" || return $?
  51. fi
  52. done
  53. __rvm_db_ "$rvm_path/config/alias" "$1" "delete"
  54. alias_after_delete_default "$1" || return $?
  55. }
  56. alias_delete()
  57. {
  58. __rvm_log_command "alias_delete" \
  59. "Deleting alias: ${1:-$alias_name}" \
  60. alias_delete_execute "${1:-$alias_name}" ||
  61. return $?
  62. }