Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run command loses double quotes from the arguments in Fork mode #7129

Open
alimg opened this issue Jan 11, 2023 · 1 comment
Open

run command loses double quotes from the arguments in Fork mode #7129

alimg opened this issue Jan 11, 2023 · 1 comment
Labels

Comments

@alimg
Copy link

alimg commented Jan 11, 2023

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

notes

@alimg alimg added the Bug label Jan 11, 2023
@dvgica
Copy link

dvgica commented Sep 15, 2023

I also hit this. It seems to be impossible to pass JSON as an argument to run without also using -Dsbt.argsfile=0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants