-
Notifications
You must be signed in to change notification settings - Fork 1k
run command loses double quotes from the arguments in Fork mode #7129
Description
steps
build.sbt to enable fork mode and configure a project so that "arguments file" mode is enabled in the fork executor:
scalaVersion := "2.13.8"
run / fork := true
// or, more commonly, have a long classpath in your project
run / javaOptions += "-Dsome.long.property=" + ("X" * 5000)
src/main/scala/Main.scala to echo out the args as is:
object Main extends App {
println(args.mkString(","))
}
On a terminal window, launch sbt and execute run command with a double quotation marks in the argument:
alim@alim-dsk ~/test/sbt/hello-world-template $ sbt
[info] welcome to sbt 1.8.2 (N/A Java 17.0.5)
[info] loading project definition from /home/alim/test/sbt/hello-world-template/project
[info] loading settings for project hello-world-template from build.sbt ...
[info] set current project to hello-world-template (in build file:/home/alim/test/sbt/hello-world-template/)
[info] sbt server started at local:///home/alim/.sbt/1.0/server/f5e16d46efd84dab5534/sock
[info] started sbt server
sbt:hello-world-template> run """{\"a\":1}"""
[info] running (fork) Main {"a":1}
[info] {a:1}
Same command produces different output when "arguments file" mode is force disabled:
alim@alim-dsk ~/test/sbt/hello-world-template $ sbt -Dsbt.argsfile=0
[info] welcome to sbt 1.8.2 (N/A Java 17.0.5)
[info] loading project definition from /home/alim/test/sbt/hello-world-template/project
[info] loading settings for project hello-world-template from build.sbt ...
[info] set current project to hello-world-template (in build file:/home/alim/test/sbt/hello-world-template/)
[info] sbt server started at local:///home/alim/.sbt/1.0/server/f5e16d46efd84dab5534/sock
[info] started sbt server
sbt:hello-world-template> run """{\"a\":1}"""
[info] running (fork) Main {"a":1}
[info] {"a":1}
[success] Total time: 0 s, completed Jan 11, 2023, 12:29:33 AM
problem
When sbt shell started without -Dsbt.argsfile=0 option, incorrect arguments passed to the launched process. I.e., it prints {a:1} instead of {"a":1} ignoring (") characters in the string. In the arguments file mode, there's no apparent way escape double quotes in command line arguments passed to the launched process.
expectation
Expected the above scenario to produce same output (printing {"a":1}) in both sbt shells launched via sbt and sbt -Dsbt.argsfile=0