Skip to content

Commit 2275440

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

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

compiler/src/dotty/tools/MainGenericRunner.scala

Lines changed: 6 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,6 +99,10 @@ 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

compiler/src/dotty/tools/scripting/Main.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ object Main:
1313
assert(rest.size >= 2, s"internal error: rest == Array(${rest.mkString(",")})")
1414

1515
val file = File(rest(1))
16+
// write script path to script.path property, so called script can see it
17+
sys.props("script.path") = file.toPath.toAbsolutePath
1618
val scriptArgs = rest.drop(2)
1719
var saveJar = false
1820
var invokeFlag = true // by default, script main method is invoked

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)