Search code examples
macosshellterminaljedit

Why doesn't jEdit work with the 'open' Unix command?


I recently installed jEdit on my Mac OS 10.6 system. I would like to be able to run jEdit in the terminal as I would emacs, i.e. 'emacs FILE.NAME'. My plan was to write a script jedit.sh containing...

touch $1
open -a /Applications/jEdit.app $1

...where the argument is the filename. Strangely, jEdit is opened but only with the default new file, not the desired file. If I substitute the 'jEdit.app' with any other app, say 'TextEdit.app', it opens the desired file.

Is there something I'm missing? Why doesn't jEdit behave like other apps when used with the 'open' command and how can I work around this?


Solution

  • First of all, 'open' is not a standard UNIX command (I assume it's something Mac OS X-specific?).

    Furthermore, jEdit is written in Java, so I assume jEdit.app is just a wrapper that starts a Java VM to execute jedit.jar (it runs /path/to/java -jar /path/to/jedit.jar or something like that, probably with extra options for memory usage etc.).

    On my Ubuntu system, the jedit wrapper script passes on whatever file I mention on the commandline, and jEdit effectively uses it, so the problem isn't with the jEdit application itself.

    Conclusion: it looks like the jEdit.app doesn't take the parameters you give it to pass them on to the java commandline...

    As a solution, try to start it as java -jar /path/to/jedit.jar "$@" from your script (AFAIK there is no need for the touch line either).