scripts/list in rvm-1.0.2 vs scripts/list in rvm-1.0.3

- old
+ new

@@ -1,7 +1,9 @@ #!/usr/bin/env bash +rvm_pretty_print=${rvm_pretty_print:-0} + rvm_base_except="selector" source "$rvm_scripts_path/base" list_gemsets() { if [[ "$1" = "strings" ]]; then @@ -12,37 +14,45 @@ current_ruby="$(__rvm_environment_identifier)" local all_rubies="$(list_strings)" printf "rvm gemsets\n" - for version in $(\ls "$rvm_gems_path/" 2> /dev/null | awk '/[a-z]*-.*/ {print $NF}') ; do + for version in $(ls "$rvm_gems_path/" 2> /dev/null | awk '/[a-z]*-.*/ {print $NF}') ; do ruby_version_name="$(echo "$version" | awk -F"$rvm_gemset_separator" '{print $1}')" [[ "$all_rubies" != *"$ruby_version_name"* ]] && continue - if echo "$version" | \grep -q '^jruby-' ; then + if echo "$version" | grep -q '^jruby-' ; then string="[ $("$rvm_rubies_path/$ruby_version_name/bin/ruby" -v | awk '{print $NF}' | sed -e 's/\[//' -e 's/\]//') ]" elif [[ -n "$(echo "$version" | awk '/^maglev-|^macruby-/')" ]] ; then string="[ x86_64 ]" else - string="[ $(file "$rvm_rubies_path/$ruby_version_name/bin/ruby" | awk '/x86.64/ {print "x86_64"} /386/ {print "i386"} /ppc/ {print "ppc"}' | \tr "\n" ' ')]" + string="[ $(file "$rvm_rubies_path/$ruby_version_name/bin/ruby" | awk '/x86.64/ {print "x86_64"} /386/ {print "i386"} /ppc/ {print "ppc"}' | tr "\n" ' ')]" fi ; unset ruby_version_name printf "\n" if [[ "$version" = "$current_ruby" ]]; then printf "=> " else printf " " fi - printf "$(tput setaf 2)$version$(tput sgr0) $string" + if [[ $rvm_pretty_print -eq 1 ]] ; then + printf "$(tput setaf 2)$version$(tput sgr0) $string" + else + printf "$version $string" + fi done ; unset version if [[ -f "$rvm_config_path/default" ]] && [[ -s "$rvm_config_path/default" ]] ; then - version=$(\grep 'MY_RUBY_HOME' "$rvm_config_path/default" | head -n1 | awk -F"'" '{print $2}' | xargs basename --) + version=$(grep 'MY_RUBY_HOME' "$rvm_config_path/default" | head -n1 | awk -F"'" '{print $2}' | xargs basename --) if [[ ! -z "$version" ]] ; then printf "\n\nDefault Ruby (for new shells)\n" - string="[ $(file "$rvm_rubies_path/$version/bin/ruby" | awk '/x86.64/ {print "x86_64"} /386/ {print "i386"} /ppc/ {print "ppc"}' | \tr "\n" ' ')]" - printf "\n $(tput setaf 2)$version$(tput sgr0) $string" + string="[ $(file "$rvm_rubies_path/$version/bin/ruby" | awk '/x86.64/ {print "x86_64"} /386/ {print "i386"} /ppc/ {print "ppc"}' | tr "\n" ' ')]" + if [[ $rvm_pretty_print -eq 1 ]] ; then + printf "\n $(tput setaf 2)$version$(tput sgr0) $string" + else + printf "\n $version $string" + fi fi ; unset version fi ; unset current_ruby version selected system_ruby system_version string binary printf "\n\n" } @@ -53,11 +63,15 @@ if [[ -L "$rvm_rubies_path/default" ]]; then version=$("$rvm_scripts_path/alias" show default 2>/dev/null | awk -F"$rvm_gemset_separator" '{print $1}' | xargs basename --) if [[ ! -z "$version" ]] ; then printf "\n\nDefault Ruby (for new shells)\n" string="[ $(file "$rvm_rubies_path/$version/bin/ruby" | awk '/x86.64/ {print "x86_64"} /386/ {print "i386"} /ppc/ {print "ppc"}' | \tr "\n" ' ')]" - printf "\n $(tput setaf 2)$version$(tput sgr0) $string\n" + if [[ $rvm_pretty_print -eq 1 ]] ; then + printf "\n $(tput setaf 2)$version$(tput sgr0) $string\n" + else + printf "\n $version $string\n" + fi fi ; unset version fi fi } @@ -71,17 +85,17 @@ } # Query for valid rvm ruby strings # This is meant to be used with scripting. list_strings() { - \ls "$rvm_rubies_path" + ls "$rvm_rubies_path" } # This is meant to be used with scripting. list_gemset_strings() { local all_rubies="$(list_strings)" - for gemset in $(\ls "$rvm_gems_path/" 2>/dev/null | xargs -n1 basename -- | \grep -v '^\(@\|doc$\|cache$\|system$\)' | sort); do + for gemset in $(ls "$rvm_gems_path/" 2>/dev/null | xargs -n1 basename -- | \grep -v '^\(@\|doc$\|cache$\|system$\)' | sort); do local ruby_name="$(echo "$gemset" | awk -F$rvm_gemset_separator '{print $1}')" [[ "$all_rubies" != *"$ruby_name"* ]] && continue echo "$gemset" done } @@ -95,11 +109,11 @@ if [[ "$1" = "strings" ]]; then list_known_strings return 0 fi - if [[ "$rvm_interactive" != "1" ]] ; then + if [[ "$rvm_interactive_flag" != "1" ]] ; then cat "$rvm_config_path/known" else ${PAGER:-less} "$rvm_config_path/known" fi } @@ -114,44 +128,53 @@ if [[ "$1" = "strings" ]]; then list_rubies_strings ; return 0 ; fi current_ruby="$(__rvm_environment_identifier | awk -F"$rvm_gemset_separator" '{print $1}')" printf "\nrvm rubies\n" - for version in $(\ls "$rvm_rubies_path/" 2> /dev/null | awk '/[a-z]*-.*/ {print $NF}') ; do - if echo "$version" | \grep -q '^jruby-' ; then + for version in $(ls "$rvm_rubies_path/" 2> /dev/null | awk '/[a-z]*-.*/ {print $NF}') ; do + if echo "$version" | grep -q '^jruby-' ; then string="[ $("$rvm_rubies_path/$version/bin/ruby" -v | awk '{print $NF}' | sed -e 's/\[//' -e 's/\]//') ]" elif [[ ! -z "$(echo "$version" | awk '/^maglev-|^macruby-/')" ]] ; then string="[ x86_64 ]" else - string="[ $(file "$rvm_rubies_path/$version/bin/ruby" | awk '/x86.64/ {print "x86_64"} /386/ {print "i386"} /ppc/ {print "ppc"}' | \tr "\n" ' ')]" + string="[ $(file "$rvm_rubies_path/$version/bin/ruby" | awk '/x86.64/ {print "x86_64"} /386/ {print "i386"} /ppc/ {print "ppc"}' | tr "\n" ' ')]" fi printf "\n" if [[ "$version" = "$current_ruby" ]]; then printf "=> " else printf " " fi # TODO: Only use tput for interactive terminal sessions. - printf "$(tput setaf 2)$version$(tput sgr0) $string" + if [[ $rvm_pretty_print -eq 1 ]] ; then + printf "$(tput setaf 2)$version$(tput sgr0) $string" + else + printf "$version $string" + fi done ; unset version if [[ -f "$rvm_config_path/default" ]] && [[ -s "$rvm_config_path/default" ]] ; then - version=$(\grep 'MY_RUBY_HOME' "$rvm_config_path/default" | head -n 1 | awk -F"'" '{print $2}' | xargs basename --) + version=$(grep 'MY_RUBY_HOME' "$rvm_config_path/default" | head -n 1 | awk -F"'" '{print $2}' | xargs basename --) if [[ ! -z "$version" ]] ; then printf "\n\nDefault Ruby (for new shells)\n" string="[ $(file "$rvm_rubies_path/$version/bin/ruby" | awk '/x86.64/ {print "x86_64"} /386/ {print "i386"} /ppc/ {print "ppc"}' | \tr "\n" ' ')]" - printf "\n $(tput setaf 2)$version$(tput sgr0) $string" + if [[ $rvm_pretty_print -eq 1 ]] ; then + printf "\n $(tput setaf 2)$version$(tput sgr0) $string" + else + printf "\n $version $string" + fi fi ; unset version fi ; unset current_ruby version selected system_ruby system_version string binary printf "\n\n" } # List all rvm installed rubies, default ruby and system ruby. # Display the rubies, indicate their architecture and indicate which is currently used. # This is not meant to be used with scripting. This is for interactive mode usage only. -action="$1" -[[ $# -gt 0 ]] && shift +args=($*) +action="${args[0]}" +args="$(echo ${args[@]:1}) " # Strip trailing / leading / extra spacing. if [[ "known" = "$action" ]] ; then list_known elif [[ "known_strings" = "$action" ]] ; then list_known_strings @@ -164,10 +187,15 @@ elif [[ "strings" = "$action" ]] ; then list_strings elif [[ "ruby_svn_tags" = "$action" ]] ; then list_ruby_svn_tags else # help - printf "\nUsage: rvm list {known,gemsets,default,rubies,strings,known_strings}" + printf " + Usage: + + rvm list {known,gemsets,default,rubies,strings,known_strings} + +" false fi exit $?