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 e9d1b6544..428c4d0a6 100644 --- a/cli/src/main/scala-2.12/coursier/cli/Bootstrap.scala +++ b/cli/src/main/scala-2.12/coursier/cli/Bootstrap.scala @@ -69,32 +69,35 @@ object Bootstrap extends CaseApp[BootstrapOptions] { private def createJarBootstrapWithPreamble(javaOpts: Seq[String], output: File, content: Array[Byte]): Unit = { val argsPartitioner = - """|sys_args="" - |app_args="" - |i=1; while [ "$i" -le $# ]; do - | eval arg=\${$i} - | case $arg in - | -J-*) - | sys_args="$sys_args ${arg#-J}" - | ;; - | *) - | app_args="$app_args $arg" - | ;; - | esac - | i=$((i + 1)) - |done + """|nargs=$# + | + |i=1; while [ "$i" -le $nargs ]; do + | eval arg=\${$i} + | case $arg in + | -J-*) set -- "$@" "${arg#-J}" ;; + | esac + | i=$((i + 1)) + | done + | + |set -- "$@" -jar "$0" + | + |i=1; while [ "$i" -le $nargs ]; do + | eval arg=\${$i} + | case $arg in + | -J-*) ;; + | *) set -- "$@" "$arg" ;; + | esac + | i=$((i + 1)) + | done + | + |shift "$nargs" |""".stripMargin val javaCmd = Seq("java") ++ javaOpts // escaping possibly a bit loose :-| .map(s => "'" + s.replace("'", "\\'") + "'") ++ - Seq( - "$sys_args", - "-jar", - "\"$0\"", - "$app_args" - ) + Seq("\"$@\"") val shellPreamble = Seq( "#!/usr/bin/env sh", diff --git a/scripts/travis.sh b/scripts/travis.sh index fc68de4e7..4157fe137 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh @@ -141,6 +141,11 @@ testBootstrap() { exit 1 fi + if [ "$(./cs-echo-launcher "-n foo")" != "-n foo" ]; then + echo "Error: unexpected output from bootstrapped echo command (generated by proguarded launcher)." 1>&2 + exit 1 + fi + # 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 -D other=thing -J -Dfoo=baz io.get-coursier:props:1.0.2