title: How to set properly SCALA_HOME in a macport installed scala
body: <p>I have installed multiple versions of Scala (2.9 and 2.10) on my mac (OS X 10.7.5) using macports. I like this way because can switch easily between these two versions by the simple "port select" command.
  But, the SCALA_HOME environment variable does not get set automatically with this command.</p>
  
  <p>Is there a proper nice macport command to set correctly the SCALA_HOME variable?
  If no, what directory should the SCALA_HOME point to in a macport installed scala?</p>
  
  <p>Thanks</p>
  
  <p>EDIT:
  Until now the best way I found is with a shell script that looks what is the current scala command and adjust the SCALA_HOME variable accordingly. I run it always after switching the Scala version.</p>
  
  <p>Here is the important command in the script. I'm not an expert shell programmer, therefore I'll be thankful for any suggestion:</p>
  
  <p><code>
  export SCALA_HOME=$(ls -l `which scala` | gawk 'match($0, "(/opt/local/share/.*)/bin/scala", a) {print a[1]}')
  </code></p>