0
if [[ -s "/usr/local/rvm/environments/ree-1.8.7-2010.02" ]] ; then
  source "/usr/local/rvm/environments/ree-1.8.7-2010.02"
  exec ruby "$@"
else
  echo "ERROR: Missing RVM environment file: '/usr/local/rvm/environments/ree-1.8.7-2010.02'" >&2
  exit 1
fi

What does '-s' do?

And what is '>&2' doing?

Blankman
  • 2,891
  • 10
  • 39
  • 68

1 Answers1

1

The -s tests that the file exists and has a size greater than 0.

The >&2 is directing the output of the echo command to stderr which is file descriptor 2.

user9517
  • 115,471
  • 20
  • 215
  • 297
  • so if the file exists, the source is loading it up in memory? – Blankman Dec 05 '10 at 21:47
  • The ree-1.8.7-2010.02 script is setting up the environment for the ruby "$@" command. Normally when you run a script it is executed in a sub-process and any environment variables created are lost when the script exits. The source command executes the commands in ree-1.8.7-2010.02 within the current shell so the environment etc are available to the ruby "$@" command. – user9517 Dec 05 '10 at 21:59
  • This is a wrapper script that is referenced inside of my nginx.conf file, so I need to set my GEM_PATH and GEM_HOME so my rails app uses those, wondering if this script is the right place. – Blankman Dec 05 '10 at 22:19