Skip to content

Instantly share code, notes, and snippets.

@halyph
Created June 19, 2011 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halyph/1034267 to your computer and use it in GitHub Desktop.
Save halyph/1034267 to your computer and use it in GitHub Desktop.
The embedding a Clojure script into a batch file
:x (comment
@echo off
java -cp clojure.jar clojure.main "%~f0" %*
goto :eof
)
(println "Hi!" *command-line-args*)
@halyph
Copy link
Author

halyph commented Jun 19, 2011

Copied from: http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Shebang_Scripting_in_Clojure
Here, the first line is seen as a label (because of the initial colon) by cmd.exe, and as a bare keyword followed by the start of a multi-line comment by Clojure. The next lines (to the closing parenthesis) run Java with an appropriate classpath, passing the batch file name ("%~f0") and the command line arguments ("%*") and then exit the batch file (goto eof). The closing parenthesis then terminates the Clojure comment, and Clojure interprets the rest of the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment