-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
info
executable file
·213 lines (152 loc) · 4.43 KB
/
info
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#!/usr/bin/env bash
if [[ "$rvm_trace_flag" -eq 2 ]] ; then set -x ; export rvm_trace_flag ; fi
source "$rvm_path/scripts/base"
source "$rvm_path/scripts/version"
version_for()
{
local binary=${1:-""}
if command -v "$binary" >/dev/null ; then
$binary --version | head -n1
else
echo "not installed"
fi
return 0
}
info_system()
{
rvm_info="
system:
uname: \"$(uname -a)\"
bash: \"$(command -v bash) => $(version_for bash)\"
zsh: \"$(command -v zsh) => $(version_for zsh)\"
"
}
info_rvm()
{
rvm_info="
rvm:
version: \"$(__rvm_version | \tr "\n" ' ' | __rvm_strip)\"
"
}
info_ruby()
{
[[ "$(__rvm_environment_identifier)" == "system" ]] && return
ruby=$(command -v ruby)
if [[ $? -eq 0 ]] && [[ -x "$ruby" ]] ; then full_version="$($ruby -v)" ; fi
rvm_info="
ruby:
interpreter: \"$(printf "${full_version}" | awk '{print $1}')\"
version: \"$(printf "${full_version}" | awk '{print $2}')\"
date: \"$(printf "${full_version}" | sed 's/^.*(\([0-9]\{4\}\(-[0-9][0-9]\)\{2\}\).*$/\1/')\"
platform: \"$(printf "${full_version}" | sed 's/^.*\[//' | sed 's/\].*$//')\"
patchlevel: \"$(printf "${full_version}" | sed 's/^.*(//' | sed 's/).*$//')\"
full_version: \"${full_version}\"
"
}
info_homes()
{
rvm_info="
homes:
gem: \"${GEM_HOME:-"not set"}\"
ruby: \"${MY_RUBY_HOME:-"not set"}\"
"
}
info_binaries()
{
rvm_info="
binaries:
ruby: \"$(command -v ruby)\"
irb: \"$(command -v irb)\"
gem: \"$(command -v gem)\"
rake: \"$(command -v rake)\"
"
}
info_environment()
{
rvm_info="
environment:
PATH: \"${PATH:-""}\"
GEM_HOME: \"${GEM_HOME:-""}\"
GEM_PATH: \"${GEM_PATH:-""}\"
MY_RUBY_HOME: \"${MY_RUBY_HOME:-""}\"
IRBRC: \"${IRBRC:-""}\"
RUBYOPT: \"${RUBYOPT:-""}\"
gemset: \"$(printf "${GEM_HOME:-""}" | awk -F${rvm_gemset_separator:-"@"} '{print $2}')\"\n
"
if [[ -n "${MAGLEV_HOME:-""}" ]] ; then
rvm_info="$rvm_info\n MAGLEV_HOME: \"$MAGLEV_HOME\""
fi
rvm_info="$rvm_info\n"
}
info_debug()
{
rvm_info="
$(__rvm_version)
$("$rvm_path/scripts/info" "$rvm_ruby_string" "" )
PATH:\n$(printf "$PATH" | awk -F":" '{print $1":"$2":"$3":"$4":"$5}' )
uname -a: $(uname -a)
permissions: $(\ls -la "$rvm_path" "$rvm_path/rubies")
"
if [[ "Darwin" = "$(uname)" ]] ; then
rvm_info="$rvm_info
uname -r: $(uname -r)
uname -m: $(uname -m)
sw_vers: $(sw_vers | \tr "\n" ',')
ARCHFLAGS: ${ARCHFLAGS:-""}
LDFLAGS: ${LDFLAGS:-""}
CFLAGS: ${CFLAGS:-""}
/Developer/SDKs/*:$(/usr/bin/basename -a /Developer/SDKs/* | \tr "\n" ',')
"
fi
for file_name in "$HOME/.bashrc" "$HOME/.bash_profile" "$HOME/.zshenv" ; do
if [[ -s "$file_name" ]] ; then
rvm_info="$rvm_info\n$file_name:\n$(\grep 'rvm' "$file_name" 2>/dev/null || true)"
fi
done
if [[ "$rvm_selfcontained" = "0" ]] ; then
debug_files=("$rvm_path/config/alias" "$rvm_path/config/system" "$rvm_path/config/db" "/etc/rvmrc" "/etc/gemrc")
else
debug_files=("$rvm_path/config/alias" "$rvm_path/config/system" "$rvm_path/config/db" "$HOME/.rvmrc" "$HOME/.gemrc")
fi
for file_name in "${debug_files[@]}" ; do
if [[ -f "$file_name" && -s "$file_name" ]] ; then
rvm_info="$rvm_info\n$file_name \(filtered\):\n$(awk '!/assword|_key/' "$file_name" )\n"
fi
done
rvm_info="$rvm_info\ngem sources:\n$(gem sources | awk '/gems/')\n\n"
}
info_sections()
{
for section in $(printf "${sections//,/ }") ; do
rvm_info="" ; "info_${section}" ; printf "$rvm_info"
done
}
rvm_ruby_gem_home="${rvm_ruby_gem_home:-${GEM_HOME:-""}}"
if [[ ! -d "$rvm_ruby_gem_home" ]] && command -v gem > /dev/null 2>&1; then
rvm_ruby_gem_home="$(gem env home)"
fi
rvm_info=""
args=($*)
ruby_strings="${args[$__array_start]// /}"
args[$__array_start]=""
args=(${args[@]})
sections="${args// /}"
all_sections="system rvm ruby homes binaries environment"
if "$rvm_path/scripts/match" "$all_sections debug" "${ruby_strings/,*/}" ; then
sections="$ruby_strings"
ruby_strings=""
fi
if [[ -z "${sections// /}" ]] ; then
sections="$all_sections"
fi
if [[ -z "$ruby_strings" ]] ; then
printf "\n$(__rvm_environment_identifier):\n"
info_sections
else
for ruby_string in $(printf ${ruby_strings//,/ }) ; do
__rvm_become "$ruby_string"
printf "\n$(__rvm_environment_identifier):\n"
info_sections
done
fi
exit 0