Because there is a limit on the length of the shebang line to as short
as 80 characters in some distributions (notably ubuntu), and the posix
standard for the shebang line does not allow you to pass any arguments
to the interperter to modify its behaviour --- so no classpath or
anything else for you!  Try it --- you'll see that the standard
shebang line just doesn't work for most project setups.  Embedding
shell gets around all these problems.

sincerely,
--Robert McIntyre

On Tue, Jan 18, 2011 at 12:03 AM, Alan <a...@malloys.org> wrote:
> On Jan 17, 7:42 am, Robert McIntyre <r...@mit.edu> wrote:
>> You can then actually run your program by making a shell script with
>> something like
>> #!/bin/bash
>> java -Xmn500M -Xms2000M -Xmx2000M -server -cp ./lib/*:./src
>> clojure.main your-namespace-file.clj  $@
>>
>> A little known fact is that the above can actually be embedded into a
>> clojure source file with the following trick:
>>
>> Make this the first line of your clojure namespace to make it executable:
>>
>> ":";exec java -verbose:gc -Xmn500M -Xms2000M -Xmx2000M -server -cp
>> "your-classpath" clojure.main $0 $*;
>>
>> The trick is putting the ":"; at the beginning and then calling exec.
>> To clojure this looks like a literal string followed by a comment.  To
>> bash it looks like a no-op followed by an invocation of java on the
>> file itself, and no lines after the first ever get executed. You can
>> make whatever class structure you cant and then just symlink the
>> clojure file to be an executable file at the base of the directory.
>> You can still always go the shell script route if you don't like the
>> embedding trick. This technique is common with emacs-lisp to make
>> things executable.
>
> Instead of a trick, why not use the fact that clojure treats #! as a
> single-line comment? Then you can write your shebang line just like
> every other scripting language.
>
> --
> 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
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to