how to pass command-line arguments to a program run with the open command?

Edit: Leaving the original answer below as some people seem to find it useful, but keep in mind that this doesn’t really answers OP’s question, this is to pass arguments to an app opened with “open” not to and app opened with Terminal.app which was opened with “open”.

You can find your answer by running open without arguments:

% open Usage: open [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-b <bundle identifier>] [-a <application>] [filenames] [--args arguments]

[…]

--args All remaining arguments are passed in argv to the application's main() function instead of opened.

[…]

You can see there is an option --args you can use it like this:

open ./Untitled.app --args arg1 arg2 arg3

I tested it on el Capitan (10.11.3) so I don’t know if the option is present in earlier versions.

Leave a Comment