Skip to content

Commit 79ea6e2

Browse files
authored
Merge pull request #12370 from dotty-staging/fix-12318
Fix #12318: Support options to repl
2 parents 0cd23ac + 71c751e commit 79ea6e2

File tree

5 files changed

+21
-22
lines changed

5 files changed

+21
-22
lines changed

dist/bin/common

+1-4
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,8 @@ JLINE_TERMINAL=$(find_lib "*jline-terminal-3*")
161161
JLINE_TERMINAL_JNA=$(find_lib "*jline-terminal-jna-3*")
162162
[[ ${conemu-} ]] || JNA=$(find_lib "*jna-5*")
163163

164-
# debug
165164

166-
DEBUG_STR=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
167-
168-
classpathArgs () {
165+
compilerJavaClasspathArgs () {
169166
# echo "dotty-compiler: $DOTTY_COMP"
170167
# echo "dotty-interface: $DOTTY_INTF"
171168
# echo "dotty-library: $DOTTY_LIB"

dist/bin/scala

+9-13
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ while [[ $# -gt 0 ]]; do
9898
addScala "$1"
9999
shift
100100
;;
101-
-d|-debug)
102-
DEBUG="${DEBUG_STR-}"
103-
shift ;;
104101
-version)
105102
# defer to scalac, then exit
106103
shift
@@ -116,8 +113,8 @@ while [[ $# -gt 0 ]]; do
116113
verbose=true
117114
addScala "-verbose"
118115
shift ;;
119-
-run|-repl)
120-
PROG_NAME="$ReplMain"
116+
-run)
117+
setExecuteMode 'run'
121118
shift ;;
122119

123120
*)
@@ -157,7 +154,7 @@ done
157154
#[ -n "${dump_args}" ] && dumpArgs ; exit 2
158155
if [ -z "${execute_mode-}" ]; then
159156
# no script was specified, set run or repl mode
160-
if [[ $options_indicator -eq 0 && "${residual_args[@]-}" == "" ]]; then
157+
if [[ $options_indicator -eq 0 ]]; then
161158
setExecuteMode 'repl'
162159
else
163160
setExecuteMode 'run'
@@ -179,15 +176,14 @@ script)
179176
else
180177
[[ $save_compiled == true ]] && rm -f $target_jar
181178
PROG_NAME=$ScriptingMain
182-
classpathArgs # initialize jvm_cp_args with toolchain classpath
179+
compilerJavaClasspathArgs # initialize jvm_cp_args with toolchain classpath
183180
scripting_string="-script $target_script ${script_args[@]}"
184181
# use eval instead of exec, to insure that onExit is subsequently called
185182

186183
# $script_cp_arg must be the first argument to $ScriptingMain
187184
# $scripting_string must be last
188185
eval "\"$JAVACMD\"" \
189186
${JAVA_OPTS:-$default_java_opts} \
190-
"${DEBUG-}" \
191187
"${java_args[@]}" \
192188
"-classpath \"$jvm_cp_args\"" \
193189
-Dscala.usejavacp=true \
@@ -210,20 +206,20 @@ repl)
210206
;;
211207

212208
run)
213-
repl_cparg="$DOTTY_LIB$PSEP$SCALA_LIB"
209+
run_cparg="$DOTTY_LIB$PSEP$SCALA_LIB"
214210
if [ -z "$CLASS_PATH" ]; then
215-
repl_cparg+="$PSEP."
211+
run_cparg+="$PSEP."
216212
else
217-
repl_cparg+="$PSEP$CLASS_PATH"
213+
run_cparg+="$PSEP$CLASS_PATH"
218214
fi
219215
if [ "$class_path_count" -gt 1 ]; then
220216
echo "warning: multiple classpaths are found, scala only use the last one."
221217
fi
222218
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"
219+
run_cparg+="$PSEP$DOTTY_COMP$PSEP$TASTY_CORE$PSEP$DOTTY_INTF$PSEP$SCALA_ASM$PSEP$DOTTY_STAGING$PSEP$DOTTY_TASTY_INSPECTOR"
224220
fi
225221
# exec here would prevent onExit from being called, leaving terminal in unusable state
226-
eval "\"$JAVACMD\"" "${DEBUG-}" "-classpath \"$repl_cparg\"" "${java_args[@]}" "${residual_args[@]}"
222+
eval "\"$JAVACMD\"" "-classpath \"$run_cparg\"" "${java_args[@]}" "${residual_args[@]}"
227223
scala_exit_status=$?
228224
;;
229225

dist/bin/scalac

+1-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ while [[ $# -gt 0 ]]; do
3636
case "$1" in
3737
--) shift; for arg; do addResidual "$arg"; done; set -- ;;
3838
-v|-verbose) verbose=true && addScala "-verbose" && shift ;;
39-
-debug) DEBUG="$DEBUG_STR" && shift ;;
4039
-q|-quiet) quiet=true && shift ;;
4140

4241
# Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222
@@ -61,7 +60,7 @@ case "$1" in
6160
esac
6261
done
6362

64-
classpathArgs
63+
compilerJavaClasspathArgs
6564

6665
if [ "$PROG_NAME" == "$ScriptingMain" ]; then
6766
setScriptName="-Dscript.path=$target_script"
@@ -72,7 +71,6 @@ fi
7271
[ -n "$script_trace" ] && set -x
7372
eval "\"$JAVACMD\"" \
7473
${JAVA_OPTS:-$default_java_opts} \
75-
"${DEBUG-}" \
7674
"${java_args[@]}" \
7775
"-classpath \"$jvm_cp_args\"" \
7876
-Dscala.usejavacp=true \

dist/bin/scaladoc

-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ while [[ $# -gt 0 ]]; do
106106
case "$1" in
107107
--) shift; for arg; do addResidual "$arg"; done; set -- ;;
108108
-v|-verbose) verbose=true && addScala "-verbose" && shift ;;
109-
-debug) DEBUG="$DEBUG_STR" && shift ;;
110109
-q|-quiet) quiet=true && shift ;;
111110

112111
-colors) colors=true && shift ;;
@@ -126,7 +125,6 @@ classpathArgs
126125

127126
eval "\"$JAVACMD\"" \
128127
${JAVA_OPTS:-$default_java_opts} \
129-
"${DEBUG-}" \
130128
"${java_args[@]}" \
131129
"${jvm_cp_args-}" \
132130
"dotty.tools.scaladoc.Main" \

project/scripts/bootstrapCmdTests

+10
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,13 @@ 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" 2>&1
73+
grep -qe "Usage: scalac <options> <source files>" "$tmp"
74+
75+
./bin/scala -help > "$tmp" 2>&1
76+
grep -qe "Usage: scala <options> <source files>" "$tmp"
77+
78+
./bin/scala -d hello.jar tests/run/hello.scala
79+
ls hello.jar

0 commit comments

Comments
 (0)