scripts/cli in rvm-0.0.61 vs scripts/cli in rvm-0.0.62

- old
+ new

@@ -3,21 +3,18 @@ function __rvm_meta { rvm_meta_author="Wayne E. Seguin" rvm_meta_author_email="wayneeseguin@gmail.com" rvm_meta_website="http://rvm.beginrescueend.com/" rvm_meta_version="$(cat $rvm_path/lib/VERSION.yml | tail -n 3 | sed 's/^.*: //g' | tr "\n" '.' | sed 's/\.$//')" - rvm_meta_updated="2009.10.19" } -function __rvm_version { __rvm_meta ; echo "rvm $rvm_meta_version ($rvm_meta_updated) [$rvm_meta_website]" ; } +function __rvm_version { __rvm_meta ; echo "rvm ${rvm_meta_version} by ${rvm_meta_author} (${rvm_meta_author_email}) [${rvm_meta_website}]" ; } function __rvm_usage { - __rvm_meta - echo -e " - rvm ${rvm_meta_version} ${rvm_meta_website} by ${rvm_meta_author} (${rvm_meta_author_email}) + $(__rvm_version) Usage rvm Action [Implementation] [Flags] [Options] @@ -92,118 +89,118 @@ --make - custom make command --make-install - custom make install command --nice - process niceness (for slow computers, default 0) -m|--gem-set - use a named gem set, instead of the default set. --rm-gem-set - Remove a named gem set + --ree-options - Options passed directly to ree's './installer' on the command line. Resources: http://rvm.beginrescueend.com/ https://www.pivotaltracker.com/projects/26822 " | ${PAGER:-less} } function __rvm_parse_args { - while [ $# -gt 0 ] ; do + while [[ $# -gt 0 ]] ; do rvm_token="$1" ; shift case "$rvm_token" in install|uninstall|path|info|setup|version|srcdir|list|reset|debug|reload|implode|readline|gemsync|update|iconv|openssl|ncurses|zlib|readline) rvm_action=$rvm_token ;; use) rvm_action=$rvm_token - if [ "ruby" = "$1" ] ; then shift ; fi + if [[ "ruby" = "$1" ]] ; then shift ; fi ;; inspect) rvm_action=$rvm_token rvm_ruby_args=$* rvm_parse_break=1 ;; rm|remove) - rvm_action=remove + rvm_action="remove" ;; system|default) rvm_action=${rvm_action:-use} rvm_ruby_interpreter="$rvm_token" ;; jruby|ree|macruby|rbx|rubinius|default|all) rvm_ruby_interpreter="$rvm_token" rvm_action="${rvm_action:-use}" - #if [ ! -z "$(echo $1 | awk '/^[0-9]/')" ] ; then + #if [[ ! -z "$(echo $1 | awk '/^[0-9]/')" ]] ; then if [[ ! -z "$1" ]] && [[ "$1" =~ ^[0-9] ]] ; then rvm_ruby_version=$1 ; shift fi ;; gems|gemset) rvm_action="gems" - if [ "name" = "$1" -o "$1" = "dir" -o "$1" = "list" -o "$1" = "empty" -o "$1" = "delete" ] ; then + if [[ "name" = "$1" ]] || [[ "dir" = "$1" ]] || [[ "list" = "$1" ]] || [[ "empty" = "$1" ]] || [[ "delete" = "$1" ]] ; then eval "rvm_${1}_flag=1" ; shift - elif [ "dump" = "$1" -o "$1" = "load" ] ; then + elif [[ "dump" = "$1" ]] || [[ "$1" = "load" ]] ; then eval "rvm_${1}_flag=1" ; shift else rvm_use_flag=1 # Default is to use the (named) gem set. fi ;; gemdir) rvm_action=$rvm_token - if [ "system" = "$1" ] ; then rvm_ruby_interpreter="system" ; shift ; fi - if [ "user" = "$1" ] ; then rvm_ruby_interpreter="user" ; shift ; fi + if [[ "system" = "$1" ]] ; then rvm_ruby_interpreter="system" ; shift ; fi + if [[ "user" = "$1" ]] ; then rvm_ruby_interpreter="user" ; shift ; fi rvm_ruby_interpreter="${rvm_ruby_interpreter:-current}" ;; --load|load|dump|clear) rvm_action="gems" eval "rvm_${rvm_token}_flag=1" ;; gemdup) rvm_action=$rvm_token - if [ -z "$1" ] ; then + if [[ -z "$1" ]] ; then rvm_ruby_interpreter="default" - elif [ "system" = "$1" ] ; then + elif [[ "system" = "$1" ]] ; then rvm_ruby_interpreter=$1 ; shift - elif [ "user" = "$1" ] ; then + elif [[ "user" = "$1" ]] ; then rvm_ruby_interpreter=$1 ; shift - elif [ "default" = "$1" ] ; then + elif [[ "default" = "$1" ]] ; then rvm_ruby_interpreter=$1 ; shift else rvm_ruby_interpreter=$1 ; shift rvm_ruby_version=$2 ; shift fi ;; do|ruby|rake|gem|rubydo|rakedo|gemdo) - if [ "do" = "$rvm_action" ] ; then rvm_action="ruby" ; fi + if [[ "do" = "$rvm_action" ]] ; then rvm_action="ruby" ; fi rvm_action=$(echo $rvm_token | sed 's#do##g') - if [ "rake" = "$rvm_action" -o "$rvm_action" = "gem" -o "$rvm_action" = "ruby" ] ; then - if [ -z "$1" ] ; then + if [[ "rake" = "$rvm_action" ]] || [[ "gem" = "$rvm_action" ]] || [[ "ruby" = "$rvm_action" ]] ; then + if [[ -z "$1" ]] ; then rvm_action="error" rvm_error_message="the 'ruby' and 'gem' actions must be followed by arguments." - rvm_parse_break=1 else rvm_action="ruby" rvm_ruby_args="$rvm_token $@" rvm_parse_break=1 fi else - if [ ! -z "$(echo $1 | awk '/^-/')" ] ; then + if [[ ! -z "$(echo $1 | awk '/^-/')" ]] ; then unset rvm_ruby_version else - if [ ! -z "$(echo $1 | awk '/^[0-9]/')" ] ; then + if [[ ! -z "$(echo $1 | awk '/^[0-9]/')" ]] ; then rvm_ruby_version=$(echo "$1" | tr ',' ' ') ; shift unset rvm_ruby_interpreter else - if [ "jruby" = "$1" -o "$1" = "rbx" -o "$1" = "rubinius" -o "$1" = "macruby" -o "$1" = "ree" -o "$1" = "ruby-enterprise" ] ; then + if [[ "jruby" = "$1" ]] || [[ "rbx" = "$1" ]] || [[ "rubinius" = "$1" ]] || [[ "macruby" = "$1" ]] || [[ "ree" = "$1" ]] || [[ "ruby-enterprise" = "$1" ]] ; then rvm_ruby_interpreter=$1 ; shift else unset rvm_ruby_interpreter rvm_ruby_version fi fi @@ -225,23 +222,23 @@ rvm_ruby_version="$rvm_token" rvm_action=${rvm_action:-use} ;; 1.2.0|1.3|1.3.0|1.3.1|1.4|1.4.0) - if [ "1.3" = "$rvm_token" ] ; then + if [[ "1.3" = "$rvm_token" ]] ; then rvm_ruby_version="1.3.1" - elif [ "1.4" = "$rvm_token" ] ; then + elif [[ "1.4" = "$rvm_token" ]] ; then rvm_ruby_version="1.4.0" else rvm_ruby_version="$rvm_token" fi rvm_ruby_interpreter=${rvm_ruby_interpreter:-jruby} rvm_action=${rvm_action:-use} ;; -v|--version) - if [ -z "$1" ] ; then + if [[ -z "$1" ]] ; then rvm_action="version" else rvm_ruby_version="$1" shift fi @@ -249,10 +246,14 @@ --repository|--repo|--url) rvm_ruby_repo_url=$rvm_token ;; + --ree-options) + rvm_ree_options="$rvm_token" + ;; + -t|--tag) rvm_ruby_tag="$1"; rvm_action="${rvm_action:-use}" shift ;; @@ -274,50 +275,50 @@ rvm_action="${rvm_action:-use}" shift ;; --bin) - if [ "update" = "$rvm_action" ] ; then + if [[ "update" = "$rvm_action" ]] ; then rvm_bin_flag=1 else rvm_bin_path="$1" ; shift fi ;; -j) - if [ ! -z "$1" ] ; then + if [[ ! -z "$1" ]] ; then rvm_make_flags="$rvm_make_flags -j$1" shift else rvm_action="error" rvm_error_message="-j *must* be followed by an integer (normally the # of CPU's in your machine)." fi ;; -C|--configure) - if [ ! -z "$1" ] ; then + if [[ ! -z "$1" ]] ; then rvm_ruby_configure="$(echo $1 | tr ',' ' ')" shift else rvm_action="error" rvm_error_message="--configure *must* be followed by configure flags." fi ;; -r|--require) - if [ -z "$1" ] ; then + if [[ -z "$1" ]] ; then rvm_action="error" rvm_error_message="-r|--require *must* be followed by a library name." else rvm_ruby_require="$rvm_ruby_require -r$1" shift fi ;; -I|--include) - if [ -z "$1" ] ; then + if [[ -z "$1" ]] ; then rvm_action="error" rvm_error_message="-I|--include *must* be followed by a path." else rvm_ruby_load_path="$rvm_ruby_load_path:$1" shift @@ -371,36 +372,37 @@ rvm_ruby_args="$*" rvm_parse_break=1 ;; *) - if [ ! -z "$rvm_token" ] ; then - if [ "gems" = "$rvm_action" ] ; then - if [ ! -z "$(echo $rvm_token | awk '/\.gems$/')" ] ; then + if [[ ! -z "$rvm_token" ]] ; then + if [[ "gems" = "$rvm_action" ]] ; then + if [[ ! -z "$(echo $rvm_token | awk '/\.gems$/')" ]] ; then rvm_file_name="$(echo $rvm_token | sed 's#\.gems##g').gems" - # elif [ ! -z "$(echo $rvm_token | awk '/\.gems$/')" ] ; then + # elif [[ ! -z "$(echo $rvm_token | awk '/\.gems$/')" ]] ; then else rvm_gem_set_name="$(echo $rvm_token | sed 's#\.gems##g')" rvm_file_name="$rvm_gem_set_name.gems" fi - elif [ ! -z "$(echo $rvm_token | awk '/,/')" ] ; then + elif [[ ! -z "$(echo $rvm_token | awk '/,/')" ]] ; then rvm_ruby_version="$rvm_token" - if [ -z "$rvm_action" ] ; then + if [[ -z "$rvm_action" ]] ; then rvm_action="do" # Not sure if we really want to do this but we'll try it out. fi - elif [ ! -z "$(echo $rvm_token | awk '/^.+%.+$/')" ] ; then + elif [[ ! -z "$(echo $rvm_token | awk '/^.+%.+$/')" ]] ; then rvm_gem_set_name="$(echo $rvm_token | awk -F'%' '{print $2}')" rvm_ruby_string="$(echo $rvm_token | awk -F'%' '{print $1}')" - #elif [ ! -z "$(echo $rvm_token | awk '/^[0-9].[0-9]/')" ] ; then + #elif [[ ! -z "$(echo $rvm_token | awk '/^[0-9].[0-9]/')" ]] ; then elif [[ ! -z "$rvm_token" ]] && [[ "$rvm_token" =~ ^[0-9].[0-9] ]] ; then rvm_ruby_string="$rvm_token" + rvm_action="${rvm_action:-rvm_token}" else - if [ ! -z "$(echo $rvm_token | awk '/\.rb$/{print}')" ] ; then # we have a specified ruby script + if [[ ! -z "$(echo $rvm_token | awk '/\.rb$/{print}')" ]] ; then # we have a specified ruby script #if [[ ! -z "$rvm_token" ]] && [[ " ! $rvm_token =~ \.rb$ ]] ; then # we have a specified ruby script rvm_ruby_args=$rvm_token rvm_ruby_file=$rvm_token - if [ -z "$rvm_action" ] ; then + if [[ -z "$rvm_action" ]] ; then rvm_action="ruby" # Not sure if we really want to do this but we'll try it out. fi else rvm_action="error" rvm_error_message="Unrecognized command line argument: '$rvm_token'" @@ -408,22 +410,21 @@ fi else rvm_action="error" rvm_error_message="Unrecognized command line argument(s): '$rvm_token $@'" fi - if [ "error" = "$rvm_action" ] ; then + if [[ "error" = "$rvm_action" ]] ; then break; fi esac - if [ -z "$rvm_action" -a ! -z "$rvm_ruby_string" ] ; then rvm_action="use" ; fi - - if [ ! -z "$rvm_parse_break" -o ! -z "$rvm_error_message" ] ; then unset rvm_parse_break; break; fi + if [[ -z "$rvm_action" ]] && [[ ! -z "$rvm_ruby_string" ]] ; then rvm_action="use" ; fi + if [[ ! -z "$rvm_parse_break" ]] || [[ ! -z "$rvm_error_message" ]] ; then unset rvm_parse_break; break; fi done - if [ ! -z "$rvm_error_message" ] ; then __rvm_pushpop ; return 1 ; fi + if [[ ! -z "$rvm_error_message" ]] ; then __rvm_pushpop ; return 1 ; fi } function rvm { trap '__rvm_cleanup_variables ; rm -rf "/tmp/rvm/$$" >/dev/null 2>&1' 0 1 2 3 15 @@ -432,31 +433,33 @@ __rvm_load_rvmrc __rvm_initialize __rvm_load_defaults __rvm_parse_args $@ - if [ -z "$rvm_trace_flag" ] ; then set +x ; else set -x ; fi + if [[ -z "$rvm_trace_flag" ]] ; then set +x ; else set -x ; fi result=0 case "$rvm_action" in use) __rvm_use ; result=$? ;; gemdir) __rvm_gemdir ; result=$? ;; gemdup) __rvm_gemdup ; result=$? ;; srcdir) __rvm_source_dir ; result=$? ;; list) __rvm_list ; result=$? ;; version) __rvm_version ; result=$? ;; reset) __rvm_reset ; result=$? ;; # TODO: how can we use bin_path here for reload, default file? - reload) __rvm_reload ; result=$? ;; implode) __rvm_implode ; result=$? ;; update) __rvm_update ; result=$? ;; readline) __rvm_readline_install ; result=$? ;; reboot) __rvm_reboot ; result=$? ;; usage|help) __rvm_usage ; result=$? ;; benchmark) __rvm_benchmark ; result=$? ;; ruby) __rvm_do ; result=$? ;; inspect) __rvm_inspect ; result=$? ;; gems) __rvm_gems ; result=$? ;; + reload) + source "$rvm_path/scripts/rvm" + ;; iconv|openssl|ncurses|zlib|readline) __rvm_${rvm_action}_install result=$? ;; @@ -478,28 +481,28 @@ ;; info|debug) __rvm_version __rvm_info - if [ "debug" = "$rvm_action" ] ; then rvm_debug_flag=1 ; __rvm_debug ; fi + if [[ "debug" = "$rvm_action" ]] ; then rvm_debug_flag=1 ; __rvm_debug ; fi ;; error) __rvm_log "fail" "$rvm_error_message ( see: 'rvm usage' )" __rvm_pushpop result=1; ;; *) - if [ ! -z "$rvm_action" ] ; then + if [[ ! -z "$rvm_action" ]] ; then __rvm_log "fail" "unknown action '$rvm_action'" else __rvm_usage fi result=1 esac - if [ "1" = "$rvm_trace_flag" ] ; then set +x ; unset rvm_trace_flag ; fi + if [[ "1" = "$rvm_trace_flag" ]] ; then set +x ; unset rvm_trace_flag ; fi return $result }