Answering my own question ...
You can check 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 also useful here, as it gives the path to where the applications installed on Homebrew are installed, are symbolically linked, not their actual installation path.
A script that works and shows this work:
#!/bin/bash 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" else 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\)\" fi
Thanks to Allendar for pointers.
dwkns source share