scripts/utility in rvm-0.0.57 vs scripts/utility in rvm-0.0.58

- old
+ new

@@ -6,26 +6,26 @@ system: uname: "$(uname -a)" ruby: - interpreter: "`echo $full_version | awk '{print $1}'`" - version: "`echo $full_version | awk '{print $2}'`" - date: "`echo $full_version | sed 's/^.*(\([0-9]\{4\}\(-[0-9][0-9]\)\{2\}\).*$/\1/'`" - platform: "`echo $full_version | sed 's/^.*\[//' | sed 's/\].*$//'`" - patchlevel: "`echo $full_version | sed 's/^.*(//' | sed 's/).*$//'`" + interpreter: "$(echo $full_version | awk '{print $1}')" + version: "$(echo $full_version | awk '{print $2}')" + date: "$(echo $full_version | sed 's/^.*(\([0-9]\{4\}\(-[0-9][0-9]\)\{2\}\).*$/\1/')" + platform: "$(echo $full_version | sed 's/^.*\[//' | sed 's/\].*$//')" + patchlevel: "$(echo $full_version | sed 's/^.*(//' | sed 's/).*$//')" full_version: "$full_version" homes: gem: "${GEM_HOME:-'not set'}" ruby: "${MY_RUBY_HOME:-'not set'}" binaries: - ruby: "`which ruby`" - irb: "`which irb`" - gem: "`which gem`" - rake: "`which rake`" + ruby: "$(which ruby)" + irb: "$(which irb)" + gem: "$(which gem)" + rake: "$(which rake)" environment: GEM_HOME: "$GEM_HOME" MY_RUBY_HOME: "$MY_RUBY_HOME" IRBRC: "$IRBRC" @@ -62,17 +62,17 @@ if [ ! -z "$2" ] ; then level=$1 ; shift ; else level="info" ; fi message=$1 case "$level" in debug) shift ; if [ ! -z "$rvm_debug_flag" ] ; then - echo -e "\033[0;35m<d>\033[0m $message \033[0;35m</d> \033[0m " + echo -e "$(tput setaf 5)<d>$(tput sgr0) $message $(tput setaf 5)</d> $(tput sgr0) " fi ;; - info) shift ; echo -e "\033[0;32m<i>\033[0m $message \033[0;32m</i> \033[0m " ;; - warn) shift ; echo -e "\033[0;33m<w>\033[0m $message \033[0;33m</w> \033[0m " ;; - error) shift ; echo -e "\033[0;31m<e>\033[0m $message \033[0;31m</e> \033[0m " ;; - fail) shift ; echo -e "\033[0;31m<f>\033[0m $message \033[0;31m</f> \033[0m " ; __rvm_pushpop ; return 1 ;; + info) shift ; echo -e "$(tput setaf 2)<i>$(tput sgr0) $message $(tput setaf 2)</i> $(tput sgr0) " ;; + warn) shift ; echo -e "$(tput setaf 3)<w>$(tput sgr0) $message $(tput setaf 3)</w> $(tput sgr0) " ;; + error) shift ; echo -e "$(tput setaf 1)<e>$(tput sgr0) $message $(tput setaf 1)</e> $(tput sgr0) " ;; + fail) shift ; echo -e "$(tput setaf 1)<f>$(tput sgr0) $message $(tput setaf 1)</f> $(tput sgr0) " ; __rvm_pushpop ; return 1 ;; *) echo -e "$message" esac } if [ ! -z "$ZSH_VERSION" ] ; then __shell_array_start=1 ; else __shell_array_start=0 ; fi @@ -103,14 +103,14 @@ if [ ! -z "$message" ] ; then __rvm_log "info" "$message" ; fi __rvm_log "debug" "Executing: $command" touch "$rvm_ruby_log_path/$log_file_name.log" "$rvm_ruby_log_path/$log_file_name.error.log" # for zsh :( echo "[$(date +'%Y-%m-%d %H:%M:%S')] $command" | tee "$rvm_ruby_log_path/$log_file_name.log" > "$rvm_ruby_log_path/$log_file_name.error.log" - if [ -z "$rvm_niceness" -o "$rvm_niceness" = "0" ] ; then + if [ -z "$rvm_niceness" -o "0" = "$rvm_niceness" ] ; then eval "$command" >> "$rvm_ruby_log_path/$log_file_name.log" 2>> "$rvm_ruby_log_path/$log_file_name.error.log" else - eval "nice -n $rvm_niceness \`$command\`" >> $rvm_ruby_log_path/$log_file_name.log 2>> $rvm_ruby_log_path/$log_file_name.error.log + eval "nice -n $rvm_niceness \$($command)" >> $rvm_ruby_log_path/$log_file_name.log 2>> $rvm_ruby_log_path/$log_file_name.error.log fi if [ $? -gt 0 ] ; then __rvm_log "error" "Error running '$command', please check $rvm_ruby_log_path/$log_file_name.error.log" ; __rvm_pushpop ; return 1 ; fi unset log_file command } @@ -271,12 +271,12 @@ function __rvm_implode { while : ; do __rvm_log "warn" "Are you SURE you wish for rvm to implode? This will remove $rvm_path ? (type 'yes' or 'no')" read response - if [ "$response" = "yes" ] ; then - if [ "$rvm_path" = "/" ] ; then + if [ "yes" = "$response" ] ; then + if [ "/" = "$rvm_path" ] ; then __rvm_log "error" "remove '/' ?!... NO!" else if [ -d $rvm_path ] ; then __rvm_log "info" "Hai! Removing $rvm_path" rm -rf $rvm_path/ @@ -284,11 +284,11 @@ else __rvm_log "info" "It appears that $rvm_path is already non existant." fi fi break - elif [ "$response" = "no" ] ; then + elif [ "no" = "$response" ] ; then __rvm_log "info" "Cancelling implosion, no harm done :)" break fi done } @@ -311,16 +311,16 @@ # clones from source implementation/version to default # TODO: Merge this into 'rvm sync' function __rvm_gemdup { if [ -z "$rvm_selected_flag" ] ; then __rvm_select $* ; fi __rvm_log "debug" "$rvm_ruby_interpreter" - if [ "$rvm_ruby_interpreter" = "default" ] ; then + if [ "default" = "$rvm_ruby_interpreter" ] ; then # TODO: ~/.rvm/default first, then system user rvm_source_gem_path="$rvm_system_user_gem_path" - elif [ "$rvm_ruby_interpreter" = "user" ] ; then + elif [ "user" = "$rvm_ruby_interpreter" ] ; then rvm_source_gem_path="$rvm_system_user_gem_path" - elif [ "$rvm_ruby_interpreter" = "system" ] ; then + elif [ "system" = "$rvm_ruby_interpreter" ] ; then rvm_source_gem_path="$rvm_system_gem_path" else # TODO: use selector for this? rvm_source_gem_path=${rvm_ruby_gem_home/$rvm_ruby_interpreter/$rvm_ruby_version} fi @@ -352,11 +352,11 @@ if [ -z "$key" ] ; then __rvm_log "fail" "__rvm_db must be called with at least one argument: __rvm_db key [value]" else value="$*" - if [ "$value" = "unset" -o "$value" = "delete" ] ; then + if [ "unset" = "$value" -o "delete" = "$value" ] ; then sed -i.tmp "s/^$key=.*$//" $rvm_hash_file else if [ -z "$value" ] ; then # get grep "^$key=" $rvm_hash_file | head -n 1 | awk -F'=' '{print $2}' else # set @@ -379,33 +379,33 @@ else current_ruby=$(which ruby | xargs dirname | xargs dirname | xargs basename 2> /dev/null) echo -e "\nruby:\n" for version in $(/bin/ls -l $rvm_path/ 2> /dev/null | awk '/ ruby-[1-2].*/ { print $NF }') ; do string=$($rvm_path/$version/bin/ruby -v) - if [ "$current_ruby" = "$version" ] ; then + if [[ "$version" = "$current_ruby" ]] ; then echo -e "=> $version : $string" selected="1" else echo -e " $version : $string" fi done ; unset version echo -e "\njruby:\n" for version in $(/bin/ls -l $rvm_path/ 2> /dev/null | awk '/jruby-.*/ { print $NF }') ; do string=$($rvm_path/$version/bin/ruby -v) - if [ "$current_ruby" = "$version" ] ; then + if [[ "$version" = "$current_ruby" ]] ; then echo -e "=> $version : $string" selected="1" else echo -e " $version : $string" fi done ; unset version echo -e "\nree:\n" for version in $(/bin/ls $rvm_path/ 2> /dev/null | awk '/ree-.*/ { print $NF }') ; do string="$($rvm_path/$version/bin/ruby -v | tr "\n" ' ' )" - if [ "$current_ruby" = "$version" ] ; then + if [[ "$version" = "$current_ruby" ]] ; then echo -e "=> $version : $string" selected="1" else echo -e " $version : $string" fi @@ -414,11 +414,11 @@ if [ -f $rvm_path/default -a -s $rvm_path/default ] ; then version=$(grep '^MY_RUBY_HOME' ~/.rvm/default | awk -F"'" '{print $2}' | xargs basename) if [ ! -z "$version" ] ; then echo -e "\ndefault:\n" string=$($rvm_path/$version/bin/ruby -v) - if [ "$current_ruby" = "$version" ] ; then + if [[ "$version" = "$current_ruby" ]] ; then echo -e "=> $version : $string" selected="1" else echo -e " $version : $string" fi @@ -426,11 +426,11 @@ fi echo -e "\nsystem:\n" system_version=$(rvm system ; ruby -v 2> /dev/null) if [ ! -z "$system_version" ] ; then - if [ "$($(which ruby) -v)" = "$system_version" ] ; then + if [[ "$($(which ruby) -v)" = "$system_version" ]] ; then echo -e "=> $system_version\n" else echo -e " $system_version\n" fi fi ; unset current_ruby version selected @@ -444,11 +444,11 @@ else rvm_fetch="$rvm_fetch -O -L --create-dirs -C - " # -s for silent fi # TODO: Sanitize user input, ensure that there is a / a the end... - if [ "$(whoami)" = "root" ] ; then + if [ "root" = "$(whoami)" ] ; then __rvm_log "fail" "root user support is not yet implemented." rvm_prefix_path="${rvm_prefix_path:-/usr/local/}" else rvm_prefix_path="${rvm_prefix_path:-"$HOME/."}" fi @@ -470,11 +470,11 @@ rvm_rubinius_repo_url="${rvm_rubinius_repo_url:-"git://github.com/evanphx/rubinius.git"}" rvm_jruby_repo_url="${rvm_jruby_repo_url:-"git://kenai.com/jruby~main"}" rvm_ruby_load_path="." rvm_ruby_require="" - if [ "$(uname)" = "Darwin" ] ; then rvm_archflags="${rvm_archflags:-'-arch i386 -arch x86_64'}" ; fi + if [ "Darwin" = "$(uname)" ] ; then rvm_archflags="${rvm_archflags:-'-arch i386 -arch x86_64'}" ; fi __rvm_clean-path rvm_result=$(echo $PATH | grep 'rvm\/bin:') if [ -z $rvm_result ] ; then PATH=$rvm_bin_path:$PATH ; export PATH @@ -482,11 +482,11 @@ mkdir -p $rvm_src_path $rvm_bin_path $rvm_archives_path $rvm_gem_path $rvm_temp_path } function __rvm_update { - if [ "$rvm_ruby_revision" = "head" -o ! -z "$rvm_self_flag" -o "$rvm_action" = "update" -o ! -z "$rvm_update_flag" ] ; then + if [ "head" = "$rvm_ruby_revision" -o ! -z "$rvm_self_flag" -o "update" = "$rvm_action" -o ! -z "$rvm_update_flag" ] ; then __rvm_version __rvm_update_rvm __rvm_version fi __rvm_reload @@ -495,11 +495,11 @@ if [ "$rvm_rubygems_flag" ] ; then __rvm_rubygems_setup ; fi } function __rvm_update_rvm { mkdir -p $rvm_src_path - if [ "$rvm_ruby_revision" = "head" ] ; then + if [ "head" = "$rvm_ruby_revision" ] ; then if [ -d $rvm_src_path/rvm/.git ] ; then cd $rvm_src_path/rvm/ && git pull origin master && ./scripts/install else cd $rvm_src_path && git clone git://github.com/wayneeseguin/rvm.git && cd rvm/ && ./install fi @@ -511,15 +511,15 @@ } function __rvm_reboot { __rvm_log "warn" "Do you wish to reset rvm? ('yes', or 'no')" read response - if [ "$response" = "yes" ] ; then + if [ "yes" = "$response" ] ; then cd __rvm_reset mv ~/.rvm/archives ~/.archives - if [ "$rvm_path" = "/" ] ; then + if [ "/" = "$rvm_path" ] ; then __rvm_log "error" "remove '/' ?!... NO!" else if [ -d $rvm_path ] ; then rm -rf $rvm_path/ fi @@ -546,14 +546,14 @@ } function __rvm_ruby_do { __rvm_select __rvm_use - binary=`echo $rvm_action | sed 's/do$//'` + binary="$(echo $rvm_action | sed 's/do$//')" if [ -x $rvm_ruby_home/bin/$binary ] ; then load_path="$rvm_ruby_home/bin:$rvm_ruby_load_path" - if [ "$binary" = "ruby" ] ; then + if [ "ruby" = "$binary" ] ; then if [ -z "$(echo $rvm_ruby_args | awk '/\.rb$/')" ] ; then rvm_ruby_args="-S $rvm_ruby_args" fi rvm_command="$rvm_ruby_home/bin/$binary $rvm_ruby_require -I$load_path $rvm_ruby_args" else @@ -589,22 +589,22 @@ # TODO: Extract the common functionality out of the if below if [ ! -z "$rvm_ruby_string" ] ; then unset rvm_ruby_interpreter rvm_ruby_version __rvm_ruby_do elif [ ! -z "$rvm_ruby_version" ] ;then - for rvm_ruby_selector in `echo $rvm_ruby_version | tr ',' ' '` ; do + for rvm_ruby_selector in $(echo $rvm_ruby_version | tr ',' ' ') ; do unset rvm_ruby_string __rvm_ruby_do done elif [ ! -z "$rvm_ruby_interpreter" ] ; then unset rvm_ruby_string rvm_ruby_version __rvm_ruby_do else # all while read bin_line do # Keep this on second line damnit! if [ -x $bin_line ] ; then - rvm_ruby_string="`dirname $bin_line | xargs dirname | xargs basename`" + rvm_ruby_string="$(dirname $bin_line | xargs dirname | xargs basename)" __rvm_ruby_do fi done < <(/bin/ls $rvm_path/*/bin/ruby 2> /dev/null) fi @@ -721,14 +721,14 @@ fi } function __rvm_state { if [ -z "$rvm_state" ] ; then - if [ -z "$(which ruby | awk /`basename $rvm_path`/)" ] ; then + if [ -z "$(which ruby | awk /$(basename $rvm_path)/)" ] ; then rvm_state=system else - rvm_state="$(dirname `which ruby` | xargs dirname | xargs basename)" + rvm_state="$(dirname $(which ruby) | xargs dirname | xargs basename)" fi else rvm_ruby_string="$rvm_state" __rvm_select __rvm_use @@ -758,11 +758,11 @@ # TODO: Figure out how to list, grab and apply the patches __rvm_log "info" "Retrieving $package-$version.$archive_format" __rvm_fetch "ftp://ftp.gnu.org/gnu/readline/$package-$version.$archive_format" __rvm_run "$package/extract" "tar zxf $rvm_archives_path/$package-$version.$archive_format -C $rvm_src_path" "Extracting $package-$version.$archive_format" cd "$rvm_src_path/$package-$version" - if [ "$(uname)" = "Darwin" ] ; then + if [ "Darwin" = "$(uname)" ] ; then sdk=$(ls -t /Developer/SDKs/ | head -n 1) CFLAGS="-isysroot /Developer/SDKs/$sdk -arch i386 -arch x86_64" LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/$sdk -arch i386 -arch x86_64" export CFLAGS LDFLAGS __rvm_run "$package/configure" "./configure --prefix=$rvm_path/usr --disable-dependency-tracking --disable-static --enable-shared" "Configuring $package" @@ -786,21 +786,20 @@ __rvm_run "$package/make.install" "/usr/bin/make install" "Installing $package to $rvm_path/usr" __rvm_pushpop } __rvm_monitor() { -if [ -d test/ ] ; then - : -elif [ -d spec/ ] ; then - : -fi -# -# timestamp() { -# if [ "$(uname)" = "Darwin" ] ; then -# $(stat -c "%Y" $1) -# else -# echo $(stat -f "%m" $1) -# fi -# } -# + if [ -d test/ ] ; then + : + elif [ -d spec/ ] ; then + : + fi +} + +timestamp() { + if [ "Darwin" = "$(uname)" ] ; then + echo $(stat -c "%Y" $1) + else + echo $(stat -f "%m" $1) + fi }