From f13589a2df1f9f55e7520498cf9db0b9a86e48b3 Mon Sep 17 00:00:00 2001 From: Jimin Hsieh Date: Tue, 12 Dec 2017 22:56:10 +0800 Subject: [PATCH 1/2] Pass JVM options to app directly. --- dist/bin/dotr | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/dist/bin/dotr b/dist/bin/dotr index bb3d06330fdb..b1866d70d378 100755 --- a/dist/bin/dotr +++ b/dist/bin/dotr @@ -27,20 +27,31 @@ if [ -z "$PROG_HOME" ] ; then cd "$saveddir" fi +addJvmOptions () { + jvm_options+=("$1") +} + source "$PROG_HOME/bin/common" declare -a residual_args -run_repl=false +execute_repl=false +execute_run=false +class_path_count=0 CLASS_PATH="" while [[ $# -gt 0 ]]; do case "$1" in -repl) - run_repl=true + execute_repl=true + shift + ;; + -run) + execute_run=true shift ;; -classpath) CLASS_PATH="$2" + class_path_count+=1 shift shift ;; @@ -48,6 +59,9 @@ while [[ $# -gt 0 ]]; do DEBUG="$DEBUG_STR" shift ;; + -J*) + addJvmOptions "${1:2}" + shift ;; *) residual_args+=("$1") shift @@ -56,18 +70,23 @@ while [[ $# -gt 0 ]]; do esac done -if [ $run_repl == true ] || [ ${#residual_args[@]} -eq 0 ]; then +if [ $execute_repl == true ] || ([ $execute_run == false ] && [ ${#residual_args[@]} -eq 0 ]); then if [ "$CLASS_PATH" ]; then cp_arg="-classpath \"$CLASS_PATH\"" fi echo "Starting dotty REPL..." eval "\"$PROG_HOME/bin/dotc\" $cp_arg -repl ${residual_args[@]}" -else +elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then cp_arg="$DOTTY_LIB$PSEP$SCALA_LIB" if [ -z "$CLASS_PATH" ]; then cp_arg+="$PSEP." else cp_arg+="$PSEP$CLASS_PATH" fi - eval exec "\"$JAVACMD\"" "$DEBUG" "-classpath \"$cp_arg\"" "${residual_args[@]}" + if [ $class_path_count > 1 ]; then + echo "warning: multiple classpaths are found, dotr only use the last one." + fi + eval exec "\"$JAVACMD\"" "$DEBUG" "-classpath \"$cp_arg\"" "${jvm_options[@]}" "${residual_args[@]}" +else + echo "warning: command option is not correct." fi From b02da804411bd25a3ad72f257c2242fbc54a9c00 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Thu, 18 Jan 2018 17:53:15 +0100 Subject: [PATCH 2/2] Add missing `-` --- dist/bin/dotr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/bin/dotr b/dist/bin/dotr index 4f8b63eb7ece..94a8926df038 100755 --- a/dist/bin/dotr +++ b/dist/bin/dotr @@ -65,7 +65,7 @@ while [[ $# -gt 0 ]]; do shift ;; -J*) - addJvmOptions "${1:2}" + addJvmOptions "-${1:2}" shift ;; *) residual_args+=("$1")