From 3b13e4f502661561e5b373e331101ba4fcad15bd Mon Sep 17 00:00:00 2001 From: Dan Wyand Date: Wed, 21 Jan 2015 23:01:37 -0500 Subject: [PATCH] :apple: try ~/Applications before using mdfind --- atom.sh | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/atom.sh b/atom.sh index 4c24692ec..2f3d59c82 100755 --- a/atom.sh +++ b/atom.sh @@ -45,18 +45,24 @@ if [ $REDIRECT_STDERR ]; then fi if [ $OS == 'Mac' ]; then - ATOM_PATH="${ATOM_PATH:-/Applications}" # Set ATOM_PATH unless it is already set ATOM_APP_NAME=Atom.app - # If ATOM_PATH isn't a executable file, use spotlight to search for Atom - if [ ! -x "$ATOM_PATH/$ATOM_APP_NAME" ]; then - ATOM_PATH="$(mdfind "kMDItemCFBundleIdentifier == 'com.github.atom'" | grep -v ShipIt | head -1 | xargs -0 dirname)" - fi + if [ -z "${ATOM_PATH}" ]; then + # If ATOM_PATH isnt set, check /Applications and then ~/Applications for Atom.app + if [ -x "/Applications/$ATOM_APP_NAME" ]; then + ATOM_PATH="/Applications" + elif [ -x "$HOME/Applications/$ATOM_APP_NAME" ]; then + ATOM_PATH="$HOME/Applications" + else + # We havent found an Atom.app, use spotlight to search for Atom + ATOM_PATH="$(mdfind "kMDItemCFBundleIdentifier == 'com.github.atom'" | grep -v ShipIt | head -1 | xargs -0 dirname)" - # Exit if Atom can't be found - if [ -z "$ATOM_PATH" ]; then - echo "Cannot locate Atom.app, it is usually located in /Applications. Set the ATOM_PATH environment variable to the directory containing Atom.app." - exit 1 + # Exit if Atom can't be found + if [ ! -x "$ATOM_PATH/$ATOM_APP_NAME" ]; then + echo "Cannot locate Atom.app, it is usually located in /Applications. Set the ATOM_PATH environment variable to the directory containing Atom.app." + exit 1 + fi + fi fi if [ $EXPECT_OUTPUT ]; then