From 41c853d28c886be659eb072c9d3c91f7f0ac1158 Mon Sep 17 00:00:00 2001 From: Ben Tucker Date: Wed, 29 Apr 2020 19:16:21 -0500 Subject: [PATCH] Fix argument passing in ash template --- .../sbt/packager/archetypes/scripts/ash-template | 4 ++-- src/sbt-test/ash/command-line-settings/build.sbt | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/resources/com/typesafe/sbt/packager/archetypes/scripts/ash-template b/src/main/resources/com/typesafe/sbt/packager/archetypes/scripts/ash-template index 28d3b2609..729d4c3f7 100644 --- a/src/main/resources/com/typesafe/sbt/packager/archetypes/scripts/ash-template +++ b/src/main/resources/com/typesafe/sbt/packager/archetypes/scripts/ash-template @@ -33,7 +33,7 @@ addJava () { } addResidual () { - residual_args="$residual_args $1" + residual_args="$residual_args \"$1\"" } # Allow user to specify java options. These get listed first per bash-template. @@ -107,4 +107,4 @@ java_cmd="$(get_java_cmd)" # If a configuration file exist, read the contents to $opts [ -f "$script_conf_file" ] && opts=$(loadConfigFile "$script_conf_file") -exec "$java_cmd" $java_opts -classpath $app_classpath $opts $app_mainclass "$residual_args" +eval "exec $java_cmd $java_opts -classpath $app_classpath $opts $app_mainclass $residual_args" diff --git a/src/sbt-test/ash/command-line-settings/build.sbt b/src/sbt-test/ash/command-line-settings/build.sbt index a9023ed37..e1b5caaa5 100644 --- a/src/sbt-test/ash/command-line-settings/build.sbt +++ b/src/sbt-test/ash/command-line-settings/build.sbt @@ -21,3 +21,12 @@ TaskKey[Unit]("checkResidual") := { val output = (sys.process.Process(cmd, cwd).!!).replaceAll("\n", "") assert(output.contains(arg), s"Application did not receive residual arg '$arg'") } + +TaskKey[Unit]("checkComplexResidual") := { + val args = """arg1 "arg 2" 'arg "3"'""" + val cwd = (stagingDirectory in Universal).value + val cmd = Seq((cwd / "bin" / packageName.value).getAbsolutePath, args) + + val output = (sys.process.Process(cmd, cwd).!!).replaceAll("\n", "") + assert(output.contains(args), s"Application did not receive residual args '$args'") +}