diff --git a/cli/src/main/scala-2.12/coursier/cli/Bootstrap.scala b/cli/src/main/scala-2.12/coursier/cli/Bootstrap.scala index 9ad4555c5..500a88977 100644 --- a/cli/src/main/scala-2.12/coursier/cli/Bootstrap.scala +++ b/cli/src/main/scala-2.12/coursier/cli/Bootstrap.scala @@ -76,9 +76,10 @@ object Bootstrap extends CaseApp[BootstrapOptions] { } val properties0 = validProperties.map { s => - val idx = s.indexOf('=') - assert(idx >= 0) - (s.take(idx), s.drop(idx + 1)) + s.split("=", 2) match { + case Array(k, v) => k -> v + case _ => sys.error("Cannot possibly happen") + } } val bootstrapJar = @@ -197,10 +198,27 @@ object Bootstrap extends CaseApp[BootstrapOptions] { outputZip.close() - // escaping of javaOpt possibly a bit loose :-| + val javaCmd = Seq("java") ++ + options + .options + .javaOpt + // escaping possibly a bit loose :-| + .map(s => "'" + s.replace("'", "\\'") + "'") ++ + properties0 + .map { + case (k, v) => + // escaping possibly a bit loose :-| + s"'-D$k=${v.replace("'", "\\'")}'" + } ++ + Seq( + "-jar", + "\"$0\"", + "\"$@\"" + ) + val shellPreamble = Seq( "#!/usr/bin/env sh", - "exec java " + options.options.javaOpt.map(s => "'" + s.replace("'", "\\'") + "'").mkString(" ") + " -jar \"$0\" \"$@\"" + "exec " + javaCmd.mkString(" ") ).mkString("", "\n", "\n") try Files.write(output0.toPath, shellPreamble.getBytes(UTF_8) ++ buffer.toByteArray) diff --git a/scripts/travis.sh b/scripts/travis.sh index 1f2ac28ac..496145c24 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh @@ -138,12 +138,17 @@ testBootstrap() { # run via the launcher rather than via the sbt-pack scripts, because the latter interprets -Dfoo=baz itself # rather than passing it to coursier since https://github.com/xerial/sbt-pack/pull/118 - ./coursier-test bootstrap -o cs-props -J -Dfoo=baz io.get-coursier:props:1.0.2 + ./coursier-test bootstrap -o cs-props -D other=thing -J -Dfoo=baz io.get-coursier:props:1.0.2 local OUT="$(./cs-props foo)" if [ "$OUT" != baz ]; then echo -e "Error: unexpected output from bootstrapped props command.\n$OUT" 1>&2 exit 1 fi + local OUT="$(./cs-props other)" + if [ "$OUT" != thing ]; then + echo -e "Error: unexpected output from bootstrapped props command.\n$OUT" 1>&2 + exit 1 + fi fi }