From 1a2ca2610beee749355488caf310f9da39ad626e Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 7 Jan 2020 13:56:35 -0500 Subject: [PATCH] Fix unintended glob expansion Fixes https://github.com/sbt/sbt/issues/5343 --- integration-test/src/test/scala/RunnerTest.scala | 10 ++++++++++ src/universal/bin/sbt | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index 0fd04878b..b907828ec 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -180,4 +180,14 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { assert(out.contains[String]("[info] HelloTest")) () } + + test("quoted * should not glob expand to local files") { + val out = sbtProcess("testOnly * ", "--no-colors", "-v", "-debug").!!.linesIterator.toList + + // Ensure the "*" doesn't get glob expanded to individual files or directories + // (e.g. Hello.scala gets added to the testOnly arguments) https://github.com/sbt/sbt/issues/5343 + assert(!out.exists(x => x.contains("testOnly") && x.contains("Hello.scala"))) + assert(out.contains[String]("[info] HelloTest")) + () + } } diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index cd9b97358..7b881031d 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -353,8 +353,8 @@ run() { local retarr=() java_args=($JAVA_OPTS) sbt_options0=(${SBT_OPTS:-$default_sbt_opts}) - miniscript=$(map_args "${sbt_options0[@]}") && eval ${miniscript/retarr/sbt_options} - miniscript=$(map_args "$@") && eval ${miniscript/retarr/args1} + miniscript=$(map_args "${sbt_options0[@]}") && eval "${miniscript/retarr/sbt_options}" + miniscript=$(map_args "$@") && eval "${miniscript/retarr/args1}" # process the combined args, then reset "$@" to the residuals process_args "${args1[@]}" vlog "[sbt_options] $(declare -p sbt_options)"