Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 243 lines (192 sloc) 5.674 kb
#!/usr/bin/env bash
if [[ "$rvm_trace_flag" -eq 2 ]] ; then set -x ; export rvm_trace_flag ; fi
source "$rvm_scripts_path/base"
source "$rvm_scripts_path/version"
version_for()
{
typeset binary
binary=${1:-""}
if builtin 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)\"
"
}
print_part()
{
(( $1 )) || return
typeset ret
ret="$1 $2"
(( $1 == 1 )) || ret="${ret}s"
printf "$ret "
}
info_rvm()
{
typeset installed_at years months days hours minutes seconds part
rvm_info="
rvm:
version: \"$(__rvm_version | \tr "\n" ' ' | __rvm_strip)\"
"
rvm_info="${rvm_info} updated: \""
installed_at="$(cat ${rvm_path}/installed.at)"
if [[ -n "${installed_at:-}" ]] && (( installed_at ))
then
seconds="$(( $(date +%s) - installed_at ))"
if (( seconds ))
then
minutes="$(( seconds / 60 % 60 ))"
hours="$(( seconds / 3600 % 24 ))"
days="$(( seconds / 86400 % 31 ))"
months="$(( seconds / 2678400 % 12 ))"
years="$(( seconds / 31536000 ))"
seconds="$(( seconds % 60 ))"
for part in year month day hour minute second
do eval "rvm_info=\"\${rvm_info}\$(print_part \${${part}s} ${part})\""
done
rvm_info="${rvm_info}ago"
else
rvm_info="${rvm_info}just now"
fi
else
rvm_info="${rvm_info}can not read installation time\n"
fi
rvm_info="${rvm_info}\"\n"
}
info_ruby()
{
[[ "$(__rvm_env_string)" == "system" ]] && return
ruby=$(builtin command -v ruby)
if [[ $? -eq 0 ]] && [[ -x "$ruby" ]] ; then full_version="$($ruby -v)" ; fi
rvm_info="
ruby:
interpreter: \"$(printf "%b" "${full_version}" | awk '{print $1}')\"
version: \"$(printf "%b" "${full_version}" | awk '{print $2}')\"
date: \"$(printf "%b" "${full_version}" | sed 's/^.*(\([0-9]\{4\}\(-[0-9][0-9]\)\{2\}\).*$/\1/')\"
platform: \"$(printf "%b" "${full_version}" | sed 's/^.*\[//' | sed 's/\].*$//')\"
patchlevel: \"$(printf "%b" "${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: \"$(__rvm_current_gemset)\"\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_scripts_path/info" "$rvm_ruby_string" "" )
PATH:\n$(printf "%b" "$PATH" | awk -F":" '{print $1":"$2":"$3":"$4":"$5}' )
uname -a: $(uname -a)
permissions: $(\ls -la "$rvm_path" "$rvm_rubies_path")
"
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_OPTIONS="" \grep 'rvm' "$file_name" 2>/dev/null || true)"
fi
done
if (( ${rvm_user_install_flag:=0} == 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 "%b" "${sections//,/ }") ; do
rvm_info=""
"info_${section}"
printf "%b" "$rvm_info"
done
}
rvm_ruby_gem_home="${rvm_ruby_gem_home:-${GEM_HOME:-""}}"
if [[ ! -d "$rvm_ruby_gem_home" ]] && builtin 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"
# TODO: Figure out what was the thought here and remove external match script
# dependency
if "$rvm_scripts_path/match" "$all_sections debug" "${ruby_strings/,*/}" ; then
sections="$ruby_strings"
ruby_strings=""
fi
if [[ -z "${sections// /}" ]] ; then
sections="$all_sections"
fi
rvm_is_a_shell_function || true
if [[ -z "$ruby_strings" ]] ; then
printf "%b" "\n$(__rvm_env_string):\n"
info_sections
else
for ruby_string in $(printf "%b" ${ruby_strings//,/ }) ; do
__rvm_become "$ruby_string"
printf "%b" "\n$(__rvm_env_string):\n"
info_sections
done
fi
exit 0
Jump to Line
Something went wrong with that request. Please try again.