Hi

On Sun, Nov 16, 2008 at 11:46 PM, Stephen C. Gilardi <[EMAIL PROTECTED]> wrote:
>
> On Nov 16, 2008, at 1:21 PM, Stuart Sierra wrote:
>
> I would like both the REPL and Script to be callable from the same main
> (), i.e. you should just be able to call java -jar clojure.jar without
> naming a class.  Default behavior would be to run a script, as with
> bash/perl/ruby, use a special command-line arg to run a REPL.  Or
> maybe imitate python, and run a REPL if there are no command-line
> args.  Either way is cool by me.
>
> If I have time today, I'll cook up some code for this.
>
> One canonical, flexible main sounds good to me too. I was mistaken about how
> things work now, though. With Rich's change today, the following already
> works as an executable script (hello.clj):

> #!/usr/bin/env java -cp /sq/ext/clojure/clojure.jar clojure.lang.Script
> (println "Hello, cores!")

> For me, that launches and runs in about 1.1 seconds of real time.
> Cool!

Using the shebang line like this is not portable.  See the following
post for details:

http://lists.freebsd.org/pipermail/freebsd-arch/2005-February/003525.html

To summarise the above post, on many operating systems if you ran a
script called scriptname.clj that started with the following shebang
line:

#!/usr/bin/env java -cp /sq/ext/clojure/clojure.jar clojure.lang.Script

it would be as if you had written:

$ /usr/bin/env "java -cp /sq/ext/clojure/clojure.jar
clojure.lang.Script" scriptname.clj

which would give you an error like:

/usr/bin/env: java -cp /sq/ext/clojure/clojure.jar
clojure.lang.Script: No such file or directory

I've just tried this on Linux with a 2.6 kernel and that's exactly what I got.

-- 
Michael Wood <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to