File tree Expand file tree Collapse file tree 1 file changed +24
-5
lines changed Expand file tree Collapse file tree 1 file changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -27,27 +27,41 @@ if [ -z "$PROG_HOME" ] ; then
27
27
cd " $saveddir "
28
28
fi
29
29
30
+ addJvmOptions () {
31
+ jvm_options+=(" $1 " )
32
+ }
33
+
30
34
source " $PROG_HOME /bin/common"
31
35
32
36
declare -a residual_args
33
- run_repl=false
37
+ execute_repl=false
38
+ execute_run=false
39
+ class_path_count=0
34
40
CLASS_PATH=" "
35
41
36
42
while [[ $# -gt 0 ]]; do
37
43
case " $1 " in
38
44
-repl)
39
- run_repl=true
45
+ execute_repl=true
46
+ shift
47
+ ;;
48
+ -run)
49
+ execute_run=true
40
50
shift
41
51
;;
42
52
-classpath)
43
53
CLASS_PATH=" $2 "
54
+ class_path_count+=1
44
55
shift
45
56
shift
46
57
;;
47
58
-d)
48
59
DEBUG=" $DEBUG_STR "
49
60
shift
50
61
;;
62
+ -J* )
63
+ addJvmOptions " ${1: 2} "
64
+ shift ;;
51
65
* )
52
66
residual_args+=(" $1 " )
53
67
shift
@@ -56,18 +70,23 @@ while [[ $# -gt 0 ]]; do
56
70
esac
57
71
done
58
72
59
- if [ $run_repl == true ] || [ ${# residual_args[@]} -eq 0 ]; then
73
+ if [ $execute_repl == true ] || ( [ $execute_run == false ] && [ $ {# residual_args[@]} -eq 0 ]) ; then
60
74
if [ " $CLASS_PATH " ]; then
61
75
cp_arg=" -classpath \" $CLASS_PATH \" "
62
76
fi
63
77
echo " Starting dotty REPL..."
64
78
eval " \" $PROG_HOME /bin/dotc\" $cp_arg -repl ${residual_args[@]} "
65
- else
79
+ elif [ $execute_repl == true ] || [ ${ # residual_args[@]} -ne 0 ] ; then
66
80
cp_arg=" $DOTTY_LIB$PSEP$SCALA_LIB "
67
81
if [ -z " $CLASS_PATH " ]; then
68
82
cp_arg+=" $PSEP ."
69
83
else
70
84
cp_arg+=" $PSEP$CLASS_PATH "
71
85
fi
72
- eval exec " \" $JAVACMD \" " " $DEBUG " " -classpath \" $cp_arg \" " " ${residual_args[@]} "
86
+ if [ $class_path_count > 1 ]; then
87
+ echo " warning: multiple classpaths are found, dotr only use the last one."
88
+ fi
89
+ eval exec " \" $JAVACMD \" " " $DEBUG " " -classpath \" $cp_arg \" " " ${jvm_options[@]} " " ${residual_args[@]} "
90
+ else
91
+ echo " warning: command option is not correct."
73
92
fi
You can’t perform that action at this time.
0 commit comments