Skip to content

Commit 7e43057

Browse files
committed
Fix cygwin problems. Handle @ and -color settings.
1 parent df72930 commit 7e43057

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

compiler/src/dotty/tools/MainGenericRunner.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ object MainGenericRunner {
7272
val classpathSeparator = File.pathSeparator
7373

7474
@sharable val javaOption = raw"""-J(.*)""".r
75-
75+
@sharable val scalaOption = raw"""@.*""".r
76+
@sharable val colorOption = raw"""-color:.*""".r
7677
@tailrec
7778
def process(args: List[String], settings: Settings): Settings = args match
7879
case Nil =>
@@ -98,12 +99,17 @@ object MainGenericRunner {
9899
process(tail, settings.withSave)
99100
case (o @ javaOption(striped)) :: tail =>
100101
process(tail, settings.withJavaArgs(striped).withScalaArgs(o))
102+
case (o @ scalaOption(_*)) :: tail =>
103+
process(tail, settings.withScalaArgs(o))
104+
case (o @ colorOption(_*)) :: tail =>
105+
process(tail, settings.withScalaArgs(o))
101106
case arg :: tail =>
102107
val line = Try(Source.fromFile(arg).getLines.toList).toOption.flatMap(_.headOption)
103108
if arg.endsWith(".scala") || arg.endsWith(".sc") || (line.nonEmpty && raw"#!.*scala".r.matches(line.get)) then
104109
settings
105110
.withExecuteMode(ExecuteMode.Script)
106111
.withTargetScript(arg)
112+
.withResidualArgs(s"-Dscript.path=$arg")
107113
.withScriptArgs(tail*)
108114
else
109115
val newSettings = if arg.startsWith("-") then settings else settings.withModeShouldBeRun

dist/bin/scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ source "$PROG_HOME/bin/common"
3030

3131
# exec here would prevent onExit from being called, leaving terminal in unusable state
3232
compilerJavaClasspathArgs
33+
[ -z "${ConEmuPID-}" -o -n "${cygwin-}" ] && export MSYSTEM= PWD= # workaround for #12405
3334
eval "\"$JAVACMD\"" "-classpath \"$jvm_cp_args\"" "dotty.tools.MainGenericRunner" "-classpath \"$jvm_cp_args\"" "$@"
3435
scala_exit_status=$?
3536

0 commit comments

Comments
 (0)