#!/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" 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 version_for() { local binary=$1 if command -v "$binary" >/dev/null ; then $binary --version | head -n1 else echo "not installed" fi } info_system() { rvm_info="$rvm_info\n system:\n uname: \"$(uname -a)\"" rvm_info="$rvm_info\n bash: \"$(command -v bash) => $(version_for bash)\"" rvm_info="$rvm_info\n zsh: \"$(command -v zsh) => $(version_for zsh)\"" rvm_info="$rvm_info\n" } info_rvm() { rvm_info="$rvm_info\n rvm:" rvm_info="$rvm_info\n version: \"$(__rvm_version | \tr "\n" ' ' | __rvm_strip)\"" rvm_info="$rvm_info\n" } info_ruby() { [[ "$(__rvm_environment_identifier)" == "system" ]] && return ruby=$(command -v ruby) if [[ $? -eq 0 ]] && [[ -x "$ruby" ]] ; then full_version="$($ruby -v)" ; fi rvm_info="$rvm_info\n ruby:" rvm_info="$rvm_info\n interpreter: \"$(printf "${full_version}" | awk '{print $1}')\"" rvm_info="$rvm_info\n version: \"$(printf "${full_version}" | awk '{print $2}')\"" rvm_info="$rvm_info\n date: \"$(printf "${full_version}" | sed 's/^.*(\([0-9]\{4\}\(-[0-9][0-9]\)\{2\}\).*$/\1/')\"" rvm_info="$rvm_info\n platform: \"$(printf "${full_version}" | sed 's/^.*\[//' | sed 's/\].*$//')\"" rvm_info="$rvm_info\n patchlevel: \"$(printf "${full_version}" | sed 's/^.*(//' | sed 's/).*$//')\"" rvm_info="$rvm_info\n full_version: \"${full_version}\"" rvm_info="$rvm_info\n" } info_homes() { rvm_info="$rvm_info\n homes:" rvm_info="$rvm_info\n gem: \"${GEM_HOME:-"not set"}\"" rvm_info="$rvm_info\n ruby: \"${MY_RUBY_HOME:-"not set"}\"" rvm_info="$rvm_info\n" } info_binaries() { rvm_info="$rvm_info\n binaries:" rvm_info="$rvm_info\n ruby: \"$(command -v ruby)\"" rvm_info="$rvm_info\n irb: \"$(command -v irb)\"" rvm_info="$rvm_info\n gem: \"$(command -v gem)\"" rvm_info="$rvm_info\n rake: \"$(command -v rake)\"" rvm_info="$rvm_info\n" } info_environment() { rvm_info="$rvm_info\n environment:" rvm_info="$rvm_info\n PATH: \"$PATH\"" rvm_info="$rvm_info\n GEM_HOME: \"$GEM_HOME\"" rvm_info="$rvm_info\n GEM_PATH: \"$GEM_PATH\"" rvm_info="$rvm_info\n BUNDLE_PATH: \"$BUNDLE_PATH\"" rvm_info="$rvm_info\n MY_RUBY_HOME: \"$MY_RUBY_HOME\"" rvm_info="$rvm_info\n IRBRC: \"$IRBRC\"" rvm_info="$rvm_info\n RUBYOPT: \"$RUBYOPT\"" rvm_info="$rvm_info\n gemset: \"$(printf "$GEM_HOME" | awk -F${rvm_gemset_separator:-'@'} '{print $2}')\"\n" if [[ ! -z "$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_info="$rvm_info\n$("$rvm_scripts_path/info" "$rvm_ruby_string" "" )" rvm_info="$rvm_info\nPATH:\n$(printf "$PATH" | awk -F":" '{print $1":"$2":"$3":"$4":"$5}' )" rvm_info="$rvm_info\nuname -a: $(uname -a)" rvm_info="$rvm_info\npermissions: $(\ls -la $rvm_path{,/rubies})" if [[ "Darwin" = "$(uname)" ]] ; then rvm_info="$rvm_info\nuname -r: $(uname -r)" rvm_info="$rvm_info\nuname -m: $(uname -m)" rvm_info="$rvm_info\nsw_vers: $(sw_vers | \tr "\n" ',')" rvm_info="$rvm_info\nARCHFLAGS: $ARCHFLAGS" rvm_info="$rvm_info\nLDFLAGS: $LDFLAGS" rvm_info="$rvm_info\nCFLAGS: $CFLAGS" rvm_info="$rvm_info\n/Developer/SDKs/*:$(/usr/bin/basename -a /Developer/SDKs/* | \tr "\n" ',')" fi for file_name in $(echo $rc_files) ; do if [[ -s "$file_name" ]] ; then rvm_info="$rvm_info\n$( "$file_name:\n$(\grep 'rvm' $file_name 2>/dev/null)" )" fi done if [[ "$rvm_selfcontained" = "0" ]] ; then debug_files="$rvm_config_path/alias $rvm_config_path/system $rvm_config_path/db /etc/rvmrc /etc/gemrc" else debug_files="$rvm_config_path/alias $rvm_config_path/system $rvm_config_path/db $HOME/.rvmrc $HOME/.gemrc" fi for file_name in $(echo $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/')" } info_sections() { for section in $(printf "${sections//,/ }") ; do unset rvm_info ; "info_${section}" ; printf "$rvm_info" done } args=($*) ruby_strings="${args[0]// /}" args="$(echo ${args[@]:1}) " # Strip trailing / leading / extra spacing. sections="${args// /}" all_sections="system rvm ruby homes binaries environment" 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 if [[ -z "$ruby_strings" ]] ; then printf "$(__rvm_environment_identifier):\n" info_sections else for ruby_string in $(printf ${ruby_strings//,/ }) ; do __rvm_become "$ruby_string" printf "$(__rvm_environment_identifier):\n" info_sections done fi exit 0