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

- old
+ new

@@ -1,18 +1,18 @@ #!/bin/bash user="$(whoami)" -if [ "root" = "$user" ] ; then +if [[ "root" = "$user" ]] ; then echo -e "$(tput setaf 1) <e> root user support is not yet implemented.$(tput sgr0)" exit 1 fi item="$(tput setaf 2)* $(tput sgr0)" question="\n$(tput setaf 2)<?>$(tput sgr0)" cwd=$(pwd) source_dir="${source_dir:-"$(dirname $0 | xargs dirname)"}" -if [ ! -d "$source_dir" ] ; then unset source_dir ; fi +if [[ ! -d "$source_dir" ]] ; then unset source_dir ; fi source_dir="${source_dir:-$cwd}" rvm_path=~/.rvm # State what is required to use rvm echo -e "\n$(tput setaf 2)rvm$(tput sgr0)\n\n shell scripts that allows a user to manage multiple ruby versions in their own account." @@ -30,87 +30,87 @@ for file_name in rvm-prompt gemsync ; do mv $rvm_path/scripts/$file_name $rvm_path/bin/ chmod +x $rvm_path/bin/$file_name done ; unset file_name -if [ -z "$rvm_loaded_flag" ] ; then +if [[ -z "$rvm_loaded_flag" ]] ; then for rcfile in .bash_profile .bashrc .zshrc ; do - if [ ! -e ~/$rcfile ] ; then touch ~/$rcfile ; fi - if [ -z "$(awk '/\.rvm\/scripts\/rvm/' ~/$rcfile)" ] ; then - echo "Adding 'if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi' to your ~/$rcfile." - echo -e "\n# rvm-install added line:\nif [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi\n" >> ~/$rcfile + if [[ ! -e ~/$rcfile ]] ; then touch ~/$rcfile ; fi + if [[ -z "$(awk '/\.rvm\/scripts\/rvm/' ~/$rcfile)" ]] ; then + echo "Adding 'if [[ -s ~/.rvm/scripts/rvm ]] ; then source ~/.rvm/scripts/rvm ; fi' to your ~/$rcfile." + echo -e "\n# rvm-install added line:\nif [[ -s ~/.rvm/scripts/rvm ]] ; then source ~/.rvm/scripts/rvm ; fi\n" >> ~/$rcfile fi done fi echo -e "\n Ensuring that rvm script location in $file is scripts/rvm not bin/rvm for: ~/.bash_profile, ~/.bashrc, ~/.zshrc..." for file in ~/.bash_profile ~/.bashrc ~/.zshrc ; do - if [ -s $file ] ; then - if [ -L $file ] ; then # If the file is a symlink, + if [[ -s $file ]] ; then + if [[ -L $file ]] ; then # If the file is a symlink, actual_file="$(readlink $file)" # read the link target so we can preserve it. else actual_file="$file" fi grep 'rvm\/bin\/rvm' $actual_file > /dev/null - if [ $? -eq 0 ] ; then + if [[ $? -eq 0 ]] ; then sed -i.orig 's#rvm/bin/rvm #rvm/scripts/rvm #g' $actual_file rm -f $actual_file.orig fi - if [ -f ~/.profile ] ; then + if [[ -f ~/.profile ]] ; then grep '.profile' $actual_file > /dev/null - if [ $? -gt 0 ] ; then + if [[ $? -gt 0 ]] ; then profile=~/.profile echo -e "\n" >> $actual_file echo "source $profile" >> $actual_file fi fi fi done -if [ -f ~/.rvm/bin/rvm ] ; then +if [[ -f ~/.rvm/bin/rvm ]] ; then echo -e "\n Removing old rvm file from ~/.rvm/bin/rvm..." rm -f ~/.rvm/bin/rvm fi system="$(uname)" echo -e "\n $(tput setaf 3)NOTES: $(tput sgr0)\n" -if [ "Linux" = "$system" ] ; then +if [[ "Linux" = "$system" ]] ; then rvm_apt_get_binary="$(which aptitude 2> /dev/null)" rvm_emerge_binary="$(which emerge 2> /dev/null)" rvm_pacman_binary="$(which pacman 2> /dev/null)" rvm_yum_binary="$(which yum 2> /dev/null)" - if [ ! -z "$rvm_apt_get_binary" ] ; then + if [[ ! -z "$rvm_apt_get_binary" ]] ; then echo -e " $item For jRuby (if you wish to use it) you will need:" echo -e " $ sudo aptitude install sun-java6-bin sun-java6-jre sun-java6-jdk" echo -e " $item For ree (if you wish to use it) you will need:" echo -e " $ sudo aptitude install libreadline5-dev libssl-dev bison" - elif [ ! -z "$rvm_emerge_binary" ] ; then + elif [[ ! -z "$rvm_emerge_binary" ]] ; then echo -e " $item For jRuby (if you wish to use it) you will need:" echo -e " $ sudo emerge dev-java/sun-jdk dev-java/sun-jre-bin" - elif [ ! -z "$rvm_pacman_binary" ] ; then + elif [[ ! -z "$rvm_pacman_binary" ]] ; then echo -e " $item For jRuby (if you wish to use it) you will need:" echo -e " $ sudo pacman -Sy jdk jre" - elif [ ! -z "$rvm_yum_binary" ] ; then + elif [[ ! -z "$rvm_yum_binary" ]] ; then echo -e " $item For ree (if you wish to use it) you will need:" echo -e " $ yum install -y rpm-build gcc gcc-c++ redhat-rpm-config ; then download and rpmbuild and install the sdk, Have fun..." else echo -e " $item For jRuby (if you wish to use it) you will need:" echo -e " The SUN java runtime environment and development kit." fi -elif [ "Darwin" = "$system" ] ; then +elif [[ "Darwin" = "$system" ]] ; then echo -e " $item Be sure that you have XCode Tools installed in order to use rvm." echo -e " $item If you intend on installing MacRuby you must install LLVM first." fi echo -e " $item In order to use rvm the following line must occur in your shell's loading files, after all path/variable settings.:" -echo -e " $item if [ -s ~/.rvm/scripts/rvm ] ; then source ~/.rvm/scripts/rvm ; fi" +echo -e " $item if [[ -s ~/.rvm/scripts/rvm ]] ; then source ~/.rvm/scripts/rvm ; fi" echo -e " $item CLOSE THIS SHELL AND OPEN A NEW ONE in order to use rvm." echo -e "\n \033[0;33mRTFM: $(tput sgr0) http://rvm.beginrescueend.com/ \n" echo -e "$(tput setaf 2)w⦿‿⦿t!$(tput sgr0)" echo -e "\n ~ Wayne\n"