summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/util/ClassPath.scala8
-rw-r--r--test/files/run/t6194.check1
-rw-r--r--test/files/run/t6194.scala8
3 files changed, 15 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala
index 8732e06502..471e2653cf 100644
--- a/src/compiler/scala/tools/nsc/util/ClassPath.scala
+++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala
@@ -15,6 +15,7 @@ import scala.reflect.ClassTag
import Jar.isJarOrZip
import File.pathSeparator
import java.net.MalformedURLException
+import java.util.regex.PatternSyntaxException
/** <p>
* This module provides star expansion of '-classpath' option arguments, behaves the same as
@@ -39,8 +40,11 @@ object ClassPath {
if (pattern == "*") lsDir(Directory("."))
else if (pattern endsWith wildSuffix) lsDir(Directory(pattern dropRight 2))
else if (pattern contains '*') {
- val regexp = ("^%s$" format pattern.replaceAll("""\*""", """.*""")).r
- lsDir(Directory(pattern).parent, regexp findFirstIn _ isDefined)
+ try {
+ val regexp = ("^" + pattern.replaceAllLiterally("""\*""", """.*""") + "$").r
+ lsDir(Directory(pattern).parent, regexp findFirstIn _ isDefined)
+ }
+ catch { case _: PatternSyntaxException => List(pattern) }
}
else List(pattern)
}
diff --git a/test/files/run/t6194.check b/test/files/run/t6194.check
new file mode 100644
index 0000000000..b325f479d7
--- /dev/null
+++ b/test/files/run/t6194.check
@@ -0,0 +1 @@
+C:\FooBar\Java\includes\*.jar
diff --git a/test/files/run/t6194.scala b/test/files/run/t6194.scala
new file mode 100644
index 0000000000..ced3259427
--- /dev/null
+++ b/test/files/run/t6194.scala
@@ -0,0 +1,8 @@
+import scala.tools.nsc.util._
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ val cp = ClassPath.expandPath("""C:\FooBar\Java\includes\*.jar""") mkString java.io.File.pathSeparator
+ println(cp)
+ }
+}