Hello world,
I've grown tired of the built-in open
Mac OS X command, mostly because it runs programs with your actual user ID instead of the effective user ID; this results in the fact sudo open Foo
opens Foo with its associated application with your account instead of the root
account, and it annoys me. So I decided to make some kind of replacement.
So far I've been successful: I can open any program under the open -a
or open -b
fashion, and support optionally waiting. I'm using NSTask
for that purpose.
However, I'd like to be able to open documents too. As far as I can see, you need to use NSWorkspace
for that, but using NSWorkspace
to launch programs results in them being launched with your account's credentials instead of your command line program's credentials. Which is precisely what the default open
tool does, and precisely what I don't want.
So, how can I have a program request that another program opens a document without using NSWorkspace
? From the NSTask
object, I can have the process ID, but that's about it.