scripts/set in rvm-1.0.2 vs scripts/set in rvm-1.0.3
- old
+ new
@@ -98,11 +98,12 @@
fi
if [[ ${#errors[*]} -gt 0 ]] ; then
summary="$summary \033[0;31m${#errors[*]} errors: $(echo "${errors[*]}" | sed 's# #, #g')\033[0m\n"
fi
total=${#rubies[*]}
- if [[ ! -z "$ZSH_VERSION" ]] ; then array_start=1 ; else array_start=0 ; fi
+ if [[ -n "${ZSH_VERSION:-""}" ]] ; then array_start=1 ; else array_start=0 ; fi
+
printf "$summary" | tee -a log/summary.log
return ${#errors[*]}
}
# Output the summary in a yaml format.
@@ -112,11 +113,11 @@
for var in ${successes[*]} ; do yaml="$yaml\n - $var" ; done
yaml="$yaml\nerrors:"
for var in ${errors[*]} ; do yaml="$yaml\n - $var" ; done
yaml="$yaml\nrubies:"
total=${#rubies[*]}
- if [[ ! -z "$ZSH_VERSION" ]] ; then array_start=1 ; else array_start=0 ; fi
+ if [[ -n "${ZSH_VERSION:-""}" ]] ; then array_start=1 ; else array_start=0 ; fi
for (( index = $array_start ; index < $total + $array_start ; index++ )) ; do
if [[ ! -z "$rvm_debug_flag" ]] ; then
"$rvm_scripts_path/log" "debug" "${rubies[$index]}: ${statuses[$index]}"
fi
yaml="$yaml\n \"${rubies[$index]}\": ${statuses[$index]}"
@@ -134,11 +135,12 @@
json="$json\n \"successful\": [$(echo \"${successes[*]}\" | sed 's# #", "#g' | sed 's#\"\"##')],"
json="$json\n \"errors\": [$(echo \"${errors[*]}\" | sed 's# #", "#g' | sed 's#\"\"##')],"
json="$json\n \"rubies\": {"
total=${#rubies[*]}
- if [[ ! -z "$ZSH_VERSION" ]] ; then array_start=1 ; else array_start=0 ; fi
+ if [[ -n "${ZSH_VERSION:-""}" ]] ; then array_start=1 ; else array_start=0 ; fi
+
for (( index = $array_start ; index < $total + $array_start ; index++ )) ; do
if [[ ! -z "$rvm_debug_flag" ]] ; then
"$rvm_scripts_path/log" "debug" "${rubies[$index]}: ${statuses[$index]}"
fi
json="$json\n {\"${rubies[$index]}\": ${statuses[$index]}}"
@@ -155,13 +157,12 @@
# Loop over a set or all rvm installed rubies to perform some action.
# Record the results and report based on CLI selections.
rubies=() ; successes=() ; errors=() ; statuses=()
-
-action="$1";
-[[ "$#" -gt 0 ]] && shift
-args="$*"
+args=($*)
+action="${args[0]}"
+args="$(echo ${args[@]:1}) " # Strip trailing / leading / extra spacing.
if [[ "$action" == "ruby" ]] && echo "$args" | \grep -q "^'--[^[:space:]]*'$" ; then
"$rvm_scripts_path/log" "warn" "You called rvm ruby with the arguments $args which look like use options."
"$rvm_scripts_path/log" "warn" "Please note that 'rvm ruby' invokes set operations instead."
fi