|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
3 | | -IFS="" |
4 | 3 | # Try to autodetect real location of the script |
5 | 4 |
|
6 | 5 | if [ -z "$PROG_HOME" ] ; then |
|
30 | 29 |
|
31 | 30 | source "$PROG_HOME/bin/common" |
32 | 31 |
|
33 | | -CLASS_PATH=".$PSEP$DOTTY_LIB$PSEP$SCALA_LIB" |
34 | | - |
35 | | -addResidual () { |
36 | | - residual_args+=("$1") |
37 | | -} |
38 | | - |
39 | | -addCustomClassPath () { |
40 | | - classpath_args+=("$1:") |
41 | | -} |
42 | | - |
| 32 | +declare -a residual_args |
43 | 33 | run_repl=false |
| 34 | +CLASS_PATH="" |
44 | 35 |
|
45 | 36 | while [[ $# -gt 0 ]]; do |
46 | | -key=$1 |
47 | | -case $key in |
48 | | - -repl) |
49 | | - run_repl=true |
50 | | - shift |
51 | | - ;; |
52 | | - -classpath) |
53 | | - addCustomClassPath "$2" |
54 | | - shift |
55 | | - shift |
56 | | - ;; |
57 | | - -d) |
58 | | - DEBUG="$DEBUG_STR" |
59 | | - shift |
60 | | - ;; |
61 | | - *) |
62 | | - addResidual "$1" |
63 | | - shift |
64 | | - ;; |
| 37 | + case "$1" in |
| 38 | + -repl) |
| 39 | + run_repl=true |
| 40 | + shift |
| 41 | + ;; |
| 42 | + -classpath) |
| 43 | + CLASS_PATH="$2" |
| 44 | + shift |
| 45 | + shift |
| 46 | + ;; |
| 47 | + -d) |
| 48 | + DEBUG="$DEBUG_STR" |
| 49 | + shift |
| 50 | + ;; |
| 51 | + *) |
| 52 | + residual_args+=("$1") |
| 53 | + shift |
| 54 | + ;; |
65 | 55 |
|
66 | 56 | esac |
67 | 57 | done |
68 | 58 |
|
69 | | -if [ $run_repl == true ]; then |
70 | | - echo "Starting dotty REPL" |
71 | | - if [ -z $classpath_args ]; then |
72 | | - classpath_args="" |
73 | | - else |
74 | | - classpath_args="-classpath \"${classpath_args[*]}\"" |
75 | | - fi |
76 | | - eval "$PROG_HOME/bin/dotc $classpath_args -repl ${residual_args[@]}" |
77 | | -elif [ -z $residual_args ]; then |
78 | | - echo "Starting dotty REPL..." |
79 | | - eval "$PROG_HOME/bin/dotc -repl" |
| 59 | +if [ $run_repl == true ] || [ ${#residual_args[@]} -eq 0 ]; then |
| 60 | + if [ "$CLASS_PATH" ]; then |
| 61 | + cp_arg="-classpath $CLASS_PATH" |
| 62 | + fi |
| 63 | + echo "Starting dotty REPL" |
| 64 | + eval "$PROG_HOME/bin/dotc $cp_arg -repl ${residual_args[@]}" |
80 | 65 | else |
81 | | - CLASS_PATH="${classpath_args[*]}$CLASS_PATH" |
82 | | - eval exec "\"$JAVACMD\"" "$DEBUG" "-classpath \"$CLASS_PATH\"" "${residual_args[@]}" |
| 66 | + cp_arg="-classpath $DOTTY_LIB$PSEP$SCALA_LIB" |
| 67 | + if [ -z "$CLASS_PATH" ]; then |
| 68 | + cp_arg+="$PSEP." |
| 69 | + else |
| 70 | + cp_arg+="$PSEP$CLASS_PATH" |
| 71 | + fi |
| 72 | + eval exec "\"$JAVACMD\"" "$DEBUG" "$cp_arg" "${residual_args[@]}" |
83 | 73 | fi |
0 commit comments