From 546a8b8949b70f03181ce49695147650e06aa373 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 16 Oct 2019 10:45:33 -0400 Subject: [PATCH 1/8] Fix verbose output for SBT_ARGS --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 050cef76d..54f39259e 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -529,7 +529,7 @@ if defined sbt_args_verbose ( if defined _JAVA_OPTS ( call :echolist !_JAVA_OPTS! ) if defined _SBT_OPTS ( call :echolist !_SBT_OPTS! ) echo -cp "!SBT_HOME!\bin\sbt-launch.jar" xsbt.boot.Boot - if defined %* ( call :echolist %* ) + if not "%*" == "" ( call :echolist %* ) echo. ) From 71a216c03757260c0a5a4f7f1d5f3a4cf776e7ca Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 16 Oct 2019 10:48:11 -0400 Subject: [PATCH 2/8] Fix -D with quotes Fixe https://github.com/sbt/sbt/issues/5192 --- src/universal/bin/sbt.bat | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 54f39259e..33d3adbf1 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -381,17 +381,22 @@ if /I "%~0" == "new" ( ) if /I "%g:~0,2%" == "-D" ( - rem special handling for -D since '=' gets parsed away - if x%g:^==% == x%g% ( - if not "%~1" == "" ( - set SBT_ARGS=!SBT_ARGS! %0=%1 - shift - goto args_loop - ) else ( - echo %g is missing a value - goto error - ) - ) + rem special handling for -D since '=' gets parsed away + echo "%g%" | find "=" > null + if ERRORLEVEL 1 ( + if not "%~1" == "" ( + set SBT_ARGS=!SBT_ARGS! %0=%1 + shift + goto args_loop + ) else ( + echo %g% is missing a value + goto error + ) + ) else ( + set SBT_ARGS=!SBT_ARGS! %~0 + echo found !SBT_ARGS! + goto args_loop + ) ) rem the %0 (instead of %~0) preserves original argument quoting @@ -550,7 +555,8 @@ rem special handling for -D since '=' gets parsed away if /I "%p:~0,2%" == "-D" ( rem if "-Dscala.ext.dirs" (replace all = with nothing) == "-Dscala.ext.dirs" rem (e.g. verify it doesn't have the = already) - if x%p:^==% == x%p% if not "%~1" == "" ( + + if "x%p:^==%" == "x%p%" if not "%~1" == "" ( echo %0=%1 shift goto echolist From 6ebad1cffca279aae134202c8e977bb5f0641ed1 Mon Sep 17 00:00:00 2001 From: Eric Peters Date: Wed, 16 Oct 2019 06:23:30 -0700 Subject: [PATCH 3/8] Add a test for -D arguments (e.g. -Dsbt.supershell=false) --- integration-test/src/test/scala/RunnerTest.scala | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/integration-test/src/test/scala/RunnerTest.scala b/integration-test/src/test/scala/RunnerTest.scala index eaec670f0..655eeb661 100755 --- a/integration-test/src/test/scala/RunnerTest.scala +++ b/integration-test/src/test/scala/RunnerTest.scala @@ -62,6 +62,12 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions { () } + test("sbt -D arguments") { + val out = sbtProcess("-Dsbt.supershell=false compile -v").!!.linesIterator.toList + assert(out.contains[String]("-Dsbt.supershell=false")) + () + } + test("sbt --sbt-version") { val out = sbtProcess("--sbt-version 1.3.0 compile -v").!!.linesIterator.toList assert(out.contains[String]("-Dsbt.version=1.3.0")) From 00e5224fdefdfb1ee9bcfbacb1a4ff86be6819d3 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 16 Oct 2019 10:53:49 -0400 Subject: [PATCH 4/8] Add debugging for -D parsing --- src/universal/bin/sbt.bat | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 33d3adbf1..20b9fd54f 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -385,7 +385,8 @@ if /I "%g:~0,2%" == "-D" ( echo "%g%" | find "=" > null if ERRORLEVEL 1 ( if not "%~1" == "" ( - set SBT_ARGS=!SBT_ARGS! %0=%1 + call :dlog [args_loop] -D argument %~0=%~1 + set "SBT_ARGS=!SBT_ARGS! %~0=%~1" shift goto args_loop ) else ( @@ -393,7 +394,8 @@ if /I "%g:~0,2%" == "-D" ( goto error ) ) else ( - set SBT_ARGS=!SBT_ARGS! %~0 + call :dlog [args_loop] -D argument %~0 + set "SBT_ARGS=!SBT_ARGS! %~0" echo found !SBT_ARGS! goto args_loop ) From 7d7e01015f592e9e9acb028527524cf427be3664 Mon Sep 17 00:00:00 2001 From: eugene yokota Date: Wed, 16 Oct 2019 11:54:22 -0400 Subject: [PATCH 5/8] Update src/universal/bin/sbt.bat Co-Authored-By: Eric Peters --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 20b9fd54f..4bae4f7ad 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -380,7 +380,7 @@ if /I "%~0" == "new" ( ) ) -if /I "%g:~0,2%" == "-D" ( +if "%g:~0,2%" == "-D" ( rem special handling for -D since '=' gets parsed away echo "%g%" | find "=" > null if ERRORLEVEL 1 ( From 3953c80c736e8db7b8e51586785ea07a3d52c03c Mon Sep 17 00:00:00 2001 From: eugene yokota Date: Wed, 16 Oct 2019 11:56:43 -0400 Subject: [PATCH 6/8] Update src/universal/bin/sbt.bat Co-Authored-By: Eric Peters --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 4bae4f7ad..2fdeb2f43 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -536,7 +536,7 @@ if defined sbt_args_verbose ( if defined _JAVA_OPTS ( call :echolist !_JAVA_OPTS! ) if defined _SBT_OPTS ( call :echolist !_SBT_OPTS! ) echo -cp "!SBT_HOME!\bin\sbt-launch.jar" xsbt.boot.Boot - if not "%*" == "" ( call :echolist %* ) + if not [%~1] == [] ( call :echolist %* ) echo. ) From 689fdd682aa4708c843998eaed5462c25dc0820f Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 16 Oct 2019 12:00:47 -0400 Subject: [PATCH 7/8] remove unnecessary /I --- src/universal/bin/sbt.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 2fdeb2f43..a9fc1617e 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -374,7 +374,7 @@ if defined _java_home_arg ( ) ) -if /I "%~0" == "new" ( +if "%~0" == "new" ( if not defined SBT_ARGS ( set sbt_new=true ) @@ -554,7 +554,7 @@ if [%0] EQU [] goto echolist_end set "p=%0" rem special handling for -D since '=' gets parsed away -if /I "%p:~0,2%" == "-D" ( +if "%p:~0,2%" == "-D" ( rem if "-Dscala.ext.dirs" (replace all = with nothing) == "-Dscala.ext.dirs" rem (e.g. verify it doesn't have the = already) From 9471fab91b0c18b16870a5ad8149ea47b708441d Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 16 Oct 2019 13:18:58 -0400 Subject: [PATCH 8/8] Remove debug echo --- src/universal/bin/sbt.bat | 1 - 1 file changed, 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index a9fc1617e..8ebfbb0ee 100755 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -396,7 +396,6 @@ if "%g:~0,2%" == "-D" ( ) else ( call :dlog [args_loop] -D argument %~0 set "SBT_ARGS=!SBT_ARGS! %~0" - echo found !SBT_ARGS! goto args_loop ) )