info 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. #!/usr/bin/env bash
  2. if
  3. [[ "$rvm_trace_flag" -eq 2 ]]
  4. then
  5. set -x
  6. export rvm_trace_flag
  7. fi
  8. source "$rvm_scripts_path/base"
  9. source "$rvm_scripts_path/functions/autolibs"
  10. source "$rvm_scripts_path/functions/detect/system"
  11. source "$rvm_scripts_path/functions/version"
  12. source "$rvm_scripts_path/functions/version-installed-when"
  13. version_for()
  14. {
  15. \typeset binary
  16. binary=${1:-""}
  17. if
  18. builtin command -v "$binary" >/dev/null
  19. then
  20. $binary --version | \command \head -n1
  21. else
  22. echo "not installed"
  23. fi
  24. }
  25. info_system()
  26. {
  27. source "$rvm_scripts_path/functions/detect/xcode"
  28. rvm_info="
  29. system:
  30. uname: \"${_system_info}\"
  31. name: \"${_system_name}\"
  32. version: \"${_system_version}\"
  33. architecture: \"${_system_arch}\"
  34. bash: \"$(command -v bash) => $(version_for bash)\"
  35. zsh: \"$(command -v zsh) => $(version_for zsh)\"
  36. remote_path: \"$(__rvm_system_path - 99 )\""
  37. [[ "$_system_name" == "OSX" ]] && rvm_info="${rvm_info}
  38. xcode: \"$(__rvm_detect_xcode_version)\""
  39. rvm_info="${rvm_info}\n"
  40. }
  41. info_rvm()
  42. {
  43. __rvm_autolibs_get
  44. __rvm_autolibs_translate_description
  45. rvm_info="
  46. rvm:
  47. version: \"${rvm_version}\"
  48. updated: \"$(__rvm_version_installed_when)\"
  49. path: \"$rvm_path\"
  50. autolibs: \"[${rvm_autolibs_flag}] ${rvm_autolibs_flag_description}\"
  51. "
  52. }
  53. info_ruby()
  54. {
  55. [[ "$(__rvm_env_string)" == "system" ]] && return
  56. ruby=$(builtin command -v ruby)
  57. if
  58. [[ $? -eq 0 ]] && [[ -x "$ruby" ]]
  59. then
  60. full_version="$($ruby -v)"
  61. fi
  62. rvm_info="
  63. ruby:
  64. interpreter: \"$(printf "%b" "${full_version}" | __rvm_awk '{print $1}')\"
  65. version: \"$(printf "%b" "${full_version}" | __rvm_awk '{print $2}')\"
  66. date: \"$(printf "%b" "${full_version}" | __rvm_sed 's/^.*(\([0-9]\{4\}\(-[0-9][0-9]\)\{2\}\).*$/\1/')\"
  67. platform: \"$(printf "%b" "${full_version}" | __rvm_sed 's/^.*\[//' | __rvm_sed 's/\].*$//')\"
  68. patchlevel: \"$(printf "%b" "${full_version}" | __rvm_sed 's/^.*(//' | __rvm_sed 's/).*$//')\"
  69. full_version: \"${full_version}\"
  70. "
  71. }
  72. info_homes()
  73. {
  74. rvm_info="
  75. homes:
  76. gem: \"${GEM_HOME:-"not set"}\"
  77. ruby: \"${MY_RUBY_HOME:-"not set"}\"
  78. "
  79. }
  80. info_binaries()
  81. {
  82. rvm_info="
  83. binaries:
  84. ruby: \"$(command -v ruby)\"
  85. irb: \"$(command -v irb)\"
  86. gem: \"$(command -v gem)\"
  87. rake: \"$(command -v rake)\"
  88. "
  89. }
  90. info_environment()
  91. {
  92. rvm_info="
  93. environment:
  94. PATH: \"${PATH:-""}\"
  95. GEM_HOME: \"${GEM_HOME:-""}\"
  96. GEM_PATH: \"${GEM_PATH:-""}\"
  97. MY_RUBY_HOME: \"${MY_RUBY_HOME:-""}\"
  98. IRBRC: \"${IRBRC:-""}\"
  99. RUBYOPT: \"${RUBYOPT:-""}\"
  100. gemset: \"$(__rvm_current_gemset)\"\n
  101. "
  102. if [[ -n "${MAGLEV_HOME:-""}" ]]
  103. then rvm_info="$rvm_info\n MAGLEV_HOME: \"$MAGLEV_HOME\""
  104. fi
  105. rvm_info="$rvm_info\n"
  106. }
  107. info_debug()
  108. {
  109. rvm_info="
  110. $(__rvm_print_headline)
  111. $("$rvm_scripts_path/info" "$rvm_ruby_string" "" )
  112. PATH:\n$(printf "%b" "$PATH" | __rvm_awk -F":" '{print $1":"$2":"$3":"$4":"$5}' )
  113. uname -a: ${_system_info}
  114. permissions: $(__rvm_ls -la "$rvm_path" "$rvm_rubies_path")
  115. "
  116. if [[ "Darwin" == "${_system_type}" ]]
  117. then
  118. rvm_info="$rvm_info
  119. sw_vers: $(sw_vers | \command \tr "\n" ',')
  120. ARCHFLAGS: ${ARCHFLAGS:-""}
  121. LDFLAGS: ${LDFLAGS:-""}
  122. CFLAGS: ${CFLAGS:-""}
  123. "
  124. fi
  125. for file_name in "$HOME/.bashrc" "$HOME/.bash_profile" "$HOME/.zshenv"
  126. do
  127. if
  128. [[ -s "$file_name" ]]
  129. then
  130. rvm_info="$rvm_info\n$file_name:\n$(__rvm_grep 'rvm' "$file_name" 2>/dev/null || true)"
  131. fi
  132. done
  133. debug_files=(
  134. "$rvm_path/config/alias" "$rvm_path/config/system" "$rvm_path/config/db"
  135. "/etc/rvmrc" "$HOME/.rvmrc" "/etc/gemrc" "$HOME/.gemrc"
  136. )
  137. for file_name in "${debug_files[@]}"
  138. do
  139. if
  140. [[ -f "$file_name" && -s "$file_name" ]]
  141. then
  142. rvm_info="$rvm_info\n$file_name \(filtered\):\n$(__rvm_awk '!/assword|_key/{print}' "$file_name" )\n"
  143. fi
  144. done
  145. rvm_info="$rvm_info\ngem sources:\n$(gem sources | __rvm_awk '/gems/{print}')\n\n"
  146. }
  147. info_sections()
  148. {
  149. for section in $(printf "%b" "${sections//,/ }")
  150. do
  151. rvm_info=""
  152. "info_${section}"
  153. printf "%b" "$rvm_info"
  154. done
  155. }
  156. rvm_ruby_gem_home="${rvm_ruby_gem_home:-${GEM_HOME:-""}}"
  157. if
  158. [[ ! -d "$rvm_ruby_gem_home" ]] &&
  159. builtin command -v gem > /dev/null 2>&1
  160. then
  161. rvm_ruby_gem_home="$(gem env home)"
  162. fi
  163. rvm_info=""
  164. args=($*)
  165. ruby_strings="${args[$__array_start]// /}"
  166. args[$__array_start]=""
  167. args=(${args[@]})
  168. sections="${args// /}"
  169. all_sections="system rvm ruby homes binaries environment"
  170. # TODO: Figure out what was the thought here and remove external match script
  171. # dependency
  172. if
  173. __rvm_string_match "$all_sections debug" "*${ruby_strings%%,*}*"
  174. then
  175. sections="$ruby_strings"
  176. ruby_strings=""
  177. fi
  178. if
  179. [[ -z "${sections// /}" ]]
  180. then
  181. sections="$all_sections"
  182. fi
  183. if
  184. [[ -z "$ruby_strings" ]]
  185. then
  186. printf "%b" "\n$(__rvm_env_string):\n"
  187. info_sections
  188. else
  189. for ruby_string in ${ruby_strings//,/ }
  190. do
  191. __rvm_become "$ruby_string"
  192. printf "%b" "\n$(__rvm_env_string):\n"
  193. info_sections
  194. done
  195. fi