> On Dec 15, 2015, at 11:47 PM, Rick Mann <rm...@latencyzero.com> wrote: > > the environment is different when launched via my app than when launched on > the command line.
— When you launch a program from a terminal, it inherits the shell’s environment, which includes variables you’ve set in startup scripts like .profile and .bashrc. — When you launch an app (from the Finder/Dock or from Xcode) there’s no shell involved, so you don’t get any customized environment variables. So if you launch e.g. Python script, it won’t have those variables either. The solution is to (a) find the user’s shell from the SHELL environment variable — yes, not everyone uses bash! I use zsh, for example. (b) launch other tools via that shell, i.e. by using NSTask to run the shell and passing the command to run as args to the shell. If the user’s shell is bash, you will have to prepend a “--login” arg to tell the shell to read your .profile script. AFAIK other shells don’t have that issue, but I could be wrong. I’ve got some oldish code that does this at: https://bitbucket.org/snej/murky/src/f7e17ba25f79e4ef10cb3743810d5d100d0bdade/Source/HgOperation.m?at=default&fileviewer=file-view-default —Jens _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com