From 8d0c1408c0dd9dd9ee241d6e80590610d55a666a Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Fri, 12 Apr 2013 12:47:45 -0400 Subject: [PATCH] Allow -cp argument to 'apply' command to be quoted. Fixes #724. --- main/command/src/main/scala/sbt/BasicCommands.scala | 8 +++----- sbt/src/sbt-test/actions/call/build.sbt | 4 ++-- sbt/src/sbt-test/actions/call/test | 6 +++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/main/command/src/main/scala/sbt/BasicCommands.scala b/main/command/src/main/scala/sbt/BasicCommands.scala index 205b53a65..b961df464 100644 --- a/main/command/src/main/scala/sbt/BasicCommands.scala +++ b/main/command/src/main/scala/sbt/BasicCommands.scala @@ -96,11 +96,9 @@ object BasicCommands token(base, compl) } private[this] def classpathOptionParser: Parser[Seq[String]] = - token( ("-cp" | "-classpath") ~> Space ) ~> rep1sep(classpathString, token(File.pathSeparatorChar)) <~ token(Space) - private[this] def classpathString: Parser[String] = - token(charClass(entryClass, "").+.string, "") - private[this] def entryClass(c: Char): Boolean = - c != File.pathSeparatorChar && !java.lang.Character.isWhitespace(c) + token( ("-cp" | "-classpath") ~> Space ) ~> classpathStrings <~ token(Space) + private[this] def classpathStrings: Parser[Seq[String]] = + token(StringBasic.map(s => IO.pathSplit(s).toSeq), "") def exit = Command.command(TerminateAction, exitBrief, exitBrief ) ( _ exit true ) diff --git a/sbt/src/sbt-test/actions/call/build.sbt b/sbt/src/sbt-test/actions/call/build.sbt index 165393b53..8ff9b8f9d 100644 --- a/sbt/src/sbt-test/actions/call/build.sbt +++ b/sbt/src/sbt-test/actions/call/build.sbt @@ -4,6 +4,6 @@ val copyOutputDir = taskKey[Unit]("Copies the compiled classes to a root-level d copyOutputDir := { val cd = (classDirectory in Compile).value - val to = baseDirectory.value / "out" + val to = baseDirectory.value / "out spaced" IO.copyDirectory(cd, to) -} \ No newline at end of file +} diff --git a/sbt/src/sbt-test/actions/call/test b/sbt/src/sbt-test/actions/call/test index 40f86f520..30bf3e1e8 100644 --- a/sbt/src/sbt-test/actions/call/test +++ b/sbt/src/sbt-test/actions/call/test @@ -1,11 +1,11 @@ # compiles a new State => State instance > compile -# puts the classes in a stable location (out/) +# puts the classes in a stable location (out spaced/ to test escaping) > copyOutputDir # checks that `apply` can load from a specific classpath -> apply -cp out demo.AddNewCommand +> 'apply -cp """out spaced/""" demo.AddNewCommand' # check that AddNewCommand was actually run # If it was, it should have registered `newCommand` -> newCommand \ No newline at end of file +> newCommand