5

Can someone elaborate the differences in OSX between running a bundled application by doing one of the following:

  • double-clicking on it
  • search for it and run it from spotlight
  • open /Application/MyApp.app

or just running its executable in Terminal:

  • $ /Application/MyApp.app/Contents/MacOS/myapp (the executable binary)
1

In most cases there is no difference. However, inside every App bundle is an Info.plist file that contains information about the App that is useful (mainly) to Mac OS X (the types of files it handles, etc.).

But the Info.plist file can also contain information about the environment that the App needs to run in. For example, the Info.plist file can contain environment variables that need to be set before the executable is launched. If you launch the executable yourself (on the command line) then those variables won't be set and the behavior of the App might be different.

EDIT: To elaborate on this a little further, if you right-click on an App and "Show Package Contents", then drill down to "Contents:MacOS" and double-click the executable icon in that directory, you will also bypass launch services and information in the Info.plist file will be ignored. So you can do in the Finder what you are doing on the command line (without command-line options, of course).

  • 2
    I was under the impression that info.plist gets read in all cases (even if called from the command line). Do you have a reference or an example which shows the contrary? – nohillside Jan 25 '14 at 10:52
  • 1
    If you run the executable directly on the command line (as the OP asked), then the new process is created by the shell with no regard for Launch Services or the settings in the Info.plist file. A way to demonstrate this is to create a shell script that writes your home directory to syslog, then use Platypus to embed it in an App bundle. Then edit the Info.plist file to override the $HOME environment variable. When you Launch the app, your overridden text will appear in syslog. But if you run the executable in the bundle at the command line, it will write your home directory to the syslog. – ithos67 Jan 25 '14 at 21:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .