Browse files

Fixed problems with spaces in params, pass CLOJURE_HOME to program

  • Loading branch information...
1 parent 9539d19 commit 613b9d9f668d710137c11da1d9a6f7e51efd8a8b @russolsen committed Jun 19, 2010
Showing with 24 additions and 16 deletions.
  1. +17 −16 bin/clj
  2. +7 −0 c_src/main.c
View
33 bin/clj
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# -----------------------------------------------------------------------------
# clj - Start Script for the Clojure interperter
# Shamelessly stolen from the Jruby startup script,
@@ -74,13 +74,12 @@ while [ -h "$PRG" ] ; do
fi
done
-CLOJURE_HOME_1=`dirname "$PRG"` # the ./bin dir
-if [ "$CLOJURE_HOME_1" = '.' ] ; then
- cwd=`pwd`
- CLOJURE_HOME=`dirname $cwd` #
-else
- CLOJURE_HOME=`dirname "$CLOJURE_HOME_1"` # the . dir
-fi
+CLOJURE_BIN=`dirname "$PRG"` # bin dir, relative
+CLOJURE_BIN=`(cd "$CLOJURE_BIN"; pwd)` # bin dir, absolute path
+echo $CLOJURE_BIN
+
+CLOJURE_HOME=`dirname "$CLOJURE_BIN"`
+echo $CLOJURE_HOME
# Determine what we are going to use for java,
# either from JAVA_HOME or from the path
@@ -117,8 +116,9 @@ done
# should be passed to clojure itself
DEBUG_CMD=""
-JAVA_ARGS=""
CLOJURE_ARGS=""
+declare -a JAVA_ARGS
+
USE_JLINE=true
USE_CONTRIB=true
@@ -148,23 +148,23 @@ do
;;
-D*)
- JAVA_ARGS="$JAVA_ARGS $1"
+ JAVA_ARGS=("${JAVA_ARGS[@]}" "$1")
;;
-X*)
- JAVA_ARGS="$JAVA_ARGS $1"
+ JAVA_ARGS=("${JAVA_ARGS[@]}" "$1")
;;
-client)
- JAVA_ARGS="$JAVA_ARGS $1"
+ JAVA_ARGS=("${JAVA_ARGS[@]}" "$1")
;;
-server)
- JAVA_ARGS="$JAVA_ARGS $1"
+ JAVA_ARGS=("${JAVA_ARGS[@]}" "$1")
;;
-hotspot)
- JAVA_ARGS="$JAVA_ARGS $1"
+ JAVA_ARGS=("${JAVA_ARGS[@]}" "$1")
;;
-no-jline)
@@ -184,7 +184,7 @@ do
-J)
arg_check "$1" $#
shift
- JAVA_ARGS="$JAVA_ARGS $1"
+ JAVA_ARGS=("${JAVA_ARGS[@]}" "$1")
;;
--)
@@ -226,8 +226,9 @@ CLOJURE_CP=`add_to_path "$CLOJURE_CP" "$LIB_DIR_CP" $CP_DELIMITER`
CLOJURE_CP=`add_to_path "$CLOJURE_CP" "$USER_CP" $CP_DELIMITER`
+$DEBUG_CMD $JAVA_CMD -DCLOJURE_HOME="$CLOJURE_HOME" \
+ -classpath "$CLOJURE_CP" "${JAVA_ARGS[@]}" $CLOJURE_JLINE_CLASS $CLOJURE_MAIN_CLASS "$@"
-$DEBUG_CMD $JAVA_CMD -classpath $CLOJURE_CP $JAVA_ARGS $CLOJURE_JLINE_CLASS $CLOJURE_MAIN_CLASS "$@"
View
7 c_src/main.c
@@ -74,8 +74,15 @@ int main(int argc, char **argv) {
char command_line[MAX_CMD_LINE_LEN];
strcat( command_line, "" );
+ // First the java command itself.
+
add_list_with_quotes( command_line, get_java_cmd(), " " );
+ // Then the -DCLOJURE_HOME=... paramter
+ strcat( command_line, " -DCLOJURE_HOME=\"" );
+ strcat( command_line, get_base_dir() );
+ strcat( command_line, "\"" );
+
add_list( command_line, get_vmargs(), " " );
add_list( command_line, "-cp ", " ");
add_list_with_quotes( command_line, classpath, " " );

0 comments on commit 613b9d9

Please sign in to comment.