The mechanism behind `open foo.app` on Mac OS X
If you type
in a Mac terminal window, or alternatively, click on foo.app in Finder the application foo will be launched.
It turns out that foo.app is actually a directory which made me wonder ‘What determines what gets launched?’
If you look inside an .app folder, you will find a Contents folder. Inside this will be, among other things, a file called Info.plist. It is this file that determines what gets launched. For example, there is an entry in this file called CFBundleExecutable that determines the executable to be launched.
Thanks to Chris Beaumont for the link above.