Created
June 19, 2011 13:19
-
-
Save halyph/1034267 to your computer and use it in GitHub Desktop.
The embedding a Clojure script into a batch file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:x (comment | |
@echo off | |
java -cp clojure.jar clojure.main "%~f0" %* | |
goto :eof | |
) | |
(println "Hi!" *command-line-args*) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.