Reputation: 3268
I want to test whether Foo.app exists before I call:
$ open -a Foo.app bar
What search path does open use to look for Foo.app? I know it must include /Applications, which means it's not $PATH.
Upvotes: 1
Views: 73
Reputation: 19641
I'd search it using mdfind
and then use the obtained path (if any) to open it:
# use head to pick the first one, replace with your favorite algorithm
FOOPATH=`mdfind "kMDItemContentTypeTree == 'com.apple.application-bundle'wc
&& kMDItemDisplayName == 'Foo'wc" | head -n 1`
if [ -d $FOOPATH ]; then
open $FOOPATH
else
echo Opps
fi
Upvotes: 1