So I have the following script saved as usr/local/bin/spawn which opens a process in a new terminal window, and then closes that window:
#!/bin/sh
osascript <<END
tell app "Terminal" to do script "$1; logout"
END
So I can do
$ spawn nano
to open a new terminal window with nano running, and when I close nano the window also closes.
However, to spawn a command with arguments, like java -jar foo.jar, I need to use
$ spawn "java -jar foo.jar"
Is there a way to change the script so that the same will work without the quotes? For example,
$ spawn java -jar foo.jar
I have tried using the trick from this answer to a question that doesn't deal with AppleScript. However that always caused Terminal.app to crash when I tried using spawn. Is there a way to escape the "$@" or a different implementation for this problem? It doesn't necessarily have to use AppleScript.