The mechanism behind `open foo.app` on Mac OS X
If you type
open foo.app
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.
Yes, when I told you about attributes and resource forks, I was thinking of ordinary files.
The behaviour described runs the app, but that is what you would expect I guess.
With ordinary files, it does mean you can call something fred.txt but set some nasty program to open it. Hence, by default – especially if you download a file – OS X warns you to be very careful.