This issue may be specific to Linux, or even to a particular version of Linux that I am using (Ubuntu 11.10 32-bit desktop), although I doubt it is. If others try this out, I'd be curious to know what your results are, especially if you know why it is happening, and how it can be fixed.
First, some behavior from a bash window on Ubuntu 11.10:
% echo hi
hi
% xdg-open
http://www.google.com
%
After pressing return for the xdg-open command above, my browser opens a tab to Google's home page. Back in the shell window, the next prompt appears immediately, even though the browser is still running and open to that page. That is what I expect to happen.
However, if I do the following commands inside of a Clojure REPL (tested Clojure 1.4 and 1.5-beta1 so far):
% rlwrap java -cp ~/lein/clojure-1.4.0/lib/clojure-1.4.0.jar clojure.main
Clojure 1.4.0
user=> (require '[clojure.java.shell :as sh])
nil
user=> (sh/sh "echo" "hi")
{:exit 0, :out "hi\n", :err ""}
user=> (sh/sh "xdg-open" "
http://www.google.com")
The invocation of echo returns immediately, printing the result and the next REPL prompt. But when I invoke xdg-open, while the browser window appears and goes to the Google home page, back in the bash window I see no return value and no new REPL prompt.
If I quit the browser, then back in the bash window I finally see the return value and a REPL prompt, as shown below:
{:exit 0, :out "", :err ""}
user=>
What I'm wishing would happen is for the return value and REPL prompt to appear very soon after pressing return when invoking xdg-open with clojure.java.shell/sh.
I added some debug print messages to a local copy of clojure.java.shell/sh, and it is stopping when waiting for the evaluation of either @out or @err in the final line of the function.
If I do the same commands above on Mac OS X, with "open" instead of "xdg-open", it all works as I expect.
Any clues?
Thanks,
Andy