I am installing Ruby on Rails on Mac OS X. The tutorial I am following says to add:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
to ~/.bash_profile
.
What does this line do?
Thanks
[[ -s "$HOME/.rvm/scripts/rvm" ]]
This portion is a test condition ([[
is the new test command). -s
returns TRUE
if the file rvm
present over at $HOME/.rvm/scripts/
location exists and is of size greater than zero
.
&&
This is a logical and
operator. It executes the statement on the right IF AND ONLY IF statement on the left returns true.
. "$HOME/.rvm/scripts/rvm"
.
is short for source
command. You are sourcing the file in your current shell and not forking a new sub-shell
It checks if the file exists and has size great than zero, and if so, it executes the file.
The file is "$HOME/.rvm/scripts/rvm
. $HOME is a variable, usually set to your homedir (~
), something like /home/youruser
. In that directory you should find a hidden folder .rvm
, which contains a folder scripts, which contains an executable file called rvm
.
I just installed rvm
and run rvm notes
as a shell command. The output includes besides other useful information the following lines.
If you wish to use RVM in an interactive fashion in other shells then place the following line at the end of your shell's loading files (.bashrc or .bash_profile for bash and .zshenv for zsh), after all PATH/variable settings:
[[ -s "/home/username/.rvm/scripts/rvm" ]] && source "/home/username/.rvm/scripts/rvm" # This loads RVM into a shell session.
I guess it is always a good idea to take a look at the latest release notes.
Also I found the "How to use RVM" screencast very helpful! It also includes information about your question in the first minutes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With