I make a clj script for running clojure as follows.
java -cp $CLOJURE_JAR:$CLASSPATH clojure.main $1
The problem is that $1 is the name of the script, so I can’t pass the argument with this.
The alternatives can be
java -cp $CLOJURE_JAR:$CLASSPATH clojure.main $1 $2 $3 $4 $5
hoping that the number of arguments is less than four, which might work, but I guess there should be a better solution to this.
What would be the better way than this?
You can use
$@to pass on all CLI arguments received by your script:If you want to omit some initial arguments, you can use e.g.
shift, which drops the current value of$1and shifts the remaining arguments so that$1assumes the old value of$2,$2that of$3etc.:For related information, see the section entitled
Special Parametersinbash‘s manpage.