Skip to content

Commit cd16ca9

Browse files
committed
Fix #12318: Support options to repl
1 parent f4d139d commit cd16ca9

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

dist/bin/common

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ JLINE_TERMINAL_JNA=$(find_lib "*jline-terminal-jna-3*")
165165

166166
DEBUG_STR=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
167167

168-
classpathArgs () {
168+
compilerJavaClasspathArgs () {
169169
# echo "dotty-compiler: $DOTTY_COMP"
170170
# echo "dotty-interface: $DOTTY_INTF"
171171
# echo "dotty-library: $DOTTY_LIB"

dist/bin/scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ while [[ $# -gt 0 ]]; do
116116
verbose=true
117117
addScala "-verbose"
118118
shift ;;
119-
-run|-repl)
120-
PROG_NAME="$ReplMain"
119+
-run)
120+
setExecuteMode 'run'
121121
shift ;;
122122

123123
*)
@@ -157,7 +157,7 @@ done
157157
#[ -n "${dump_args}" ] && dumpArgs ; exit 2
158158
if [ -z "${execute_mode-}" ]; then
159159
# no script was specified, set run or repl mode
160-
if [[ $options_indicator -eq 0 && "${residual_args[@]-}" == "" ]]; then
160+
if [[ $options_indicator -eq 0 ]]; then
161161
setExecuteMode 'repl'
162162
else
163163
setExecuteMode 'run'
@@ -179,7 +179,7 @@ script)
179179
else
180180
[[ $save_compiled == true ]] && rm -f $target_jar
181181
PROG_NAME=$ScriptingMain
182-
classpathArgs # initialize jvm_cp_args with toolchain classpath
182+
compilerJavaClasspathArgs # initialize jvm_cp_args with toolchain classpath
183183
scripting_string="-script $target_script ${script_args[@]}"
184184
# use eval instead of exec, to insure that onExit is subsequently called
185185

@@ -210,20 +210,20 @@ repl)
210210
;;
211211

212212
run)
213-
repl_cparg="$DOTTY_LIB$PSEP$SCALA_LIB"
213+
run_cparg="$DOTTY_LIB$PSEP$SCALA_LIB"
214214
if [ -z "$CLASS_PATH" ]; then
215-
repl_cparg+="$PSEP."
215+
run_cparg+="$PSEP."
216216
else
217-
repl_cparg+="$PSEP$CLASS_PATH"
217+
run_cparg+="$PSEP$CLASS_PATH"
218218
fi
219219
if [ "$class_path_count" -gt 1 ]; then
220220
echo "warning: multiple classpaths are found, scala only use the last one."
221221
fi
222222
if [ $with_compiler == true ]; then
223-
repl_cparg+="$PSEP$DOTTY_COMP$PSEP$TASTY_CORE$PSEP$DOTTY_INTF$PSEP$SCALA_ASM$PSEP$DOTTY_STAGING$PSEP$DOTTY_TASTY_INSPECTOR"
223+
run_cparg+="$PSEP$DOTTY_COMP$PSEP$TASTY_CORE$PSEP$DOTTY_INTF$PSEP$SCALA_ASM$PSEP$DOTTY_STAGING$PSEP$DOTTY_TASTY_INSPECTOR"
224224
fi
225225
# exec here would prevent onExit from being called, leaving terminal in unusable state
226-
eval "\"$JAVACMD\"" "${DEBUG-}" "-classpath \"$repl_cparg\"" "${java_args[@]}" "${residual_args[@]}"
226+
eval "\"$JAVACMD\"" "${DEBUG-}" "-classpath \"$run_cparg\"" "${java_args[@]}" "${residual_args[@]}"
227227
scala_exit_status=$?
228228
;;
229229

dist/bin/scalac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ case "$1" in
6161
esac
6262
done
6363

64-
classpathArgs
64+
compilerJavaClasspathArgs
6565

6666
if [ "$PROG_NAME" == "$ScriptingMain" ]; then
6767
setScriptName="-Dscript.path=$target_script"

project/scripts/bootstrapCmdTests

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,10 @@ clear_out "$OUT"
6767

6868
# check options specified in files
6969
./bin/scalac @project/scripts/options "$SOURCE"
70+
71+
# test command line options
72+
./bin/scalac -help > "$tmp"
73+
grep -qe "Usage: scalac <options> <source files>" "$tmp"
74+
75+
./bin/scala -help > "$tmp"
76+
grep -qe "Usage: scalac <options> <source files>" "$tmp"

0 commit comments

Comments
 (0)