Find the install location of brew on OS X

Answering my own question...

You can test the output of which brew and deal with things accordingly. To gracefully deal with the case where Homebrew is not installed you can use if which brew 2> /dev/null which redirects stderr to /dev/null.

brew --prefix is also useful here as it give the path to where Homebrew installed applications are symlinked to, rather than their actual install path.

A script which works and shows this working :

if which brew 2> /dev/null; then
    brewLocation=`which brew`
    appLocation=`brew --prefix`
    echo "Homebrew is installed in $brewLocation"
    echo "Homebrew apps are run from $appLocation"
   echo "Can't find Homebrew"
   echo "To install it open a Terminal window and type :"
   echo /usr/bin/ruby -e \"\$\(curl\ \-fsSL\ https\:\/\/raw\.github\.com\/Homebrew\/homebrew\/go\/install\)\"

Thanks to Allendar for the pointers.