how to pass command-line arguments to a program run with the open command?
Probably the easiest way is to create a temporary shell script, e.g.
$ echo "~/my_executable arg1 arg2" > /tmp/tmp.sh ; chmod +x /tmp/tmp.sh ; open -a Terminal /tmp/tmp.sh ; rm /tmp/tmp.sh
Yes, I know. need to manage another script. but think differently. you work not on Terminal, but on Script Editor. (not bash scripting, but AppleScript'ing)
property testScript : "/tmp/sh.sh"
set input to display dialog "args?" default answer ""
log input
tell application "Terminal"
activate
do script testScript & " " & text returned of input
end tell
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.