Skip to content

Instantly share code, notes, and snippets.

@raphamorim
Created September 27, 2016 21:59
Show Gist options
  • Save raphamorim/fd8285d3f7750c274e3e9b54febc49f1 to your computer and use it in GitHub Desktop.
Save raphamorim/fd8285d3f7750c274e3e9b54febc49f1 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Parts of this file come from:
# http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started#Create_clj_Script
BREAK_CHARS="\(\){}[],^%$#@\"\";:''|\\"
CLOJURE_DIR=/usr/local/lib/clojure
CLOJURE_JAR=$CLOJURE_DIR/clojure.jar
CLASSPATH="$CLOJURE_DIR/*:$CLOJURE_JAR"
while [ $# -gt 0 ]
do
case "$1" in
-cp|-classpath)
CLASSPATH="$CLASSPATH:$2"
shift ; shift
;;
-e) tmpfile="/tmp/`basename $0`.$$.tmp"
echo "$2" > "$tmpfile"
shift ; shift
set "$tmpfile" "$@"
break # forces any -cp to be before any -e
;;
*) break
;;
esac
done
if [ $# -eq 0 ]
then
exec rlwrap --remember -c -b $BREAK_CHARS \
java -cp $CLASSPATH clojure.main
else
exec java -cp $CLASSPATH clojure.main $1 -- "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment