From 28f795730736b1b92f3e10afb8ea5c72b97e4823 Mon Sep 17 00:00:00 2001 From: MkDev11 Date: Tue, 13 Jan 2026 05:19:19 -0500 Subject: [PATCH] [2.x] fix: Fix sbt new argument parsing on Windows (#8509) Only recombine split -- arguments after new/init command. Fixes #7507 --- launcher-package/src/universal/bin/sbt.bat | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/launcher-package/src/universal/bin/sbt.bat b/launcher-package/src/universal/bin/sbt.bat index 35587934f..0d47ca935 100755 --- a/launcher-package/src/universal/bin/sbt.bat +++ b/launcher-package/src/universal/bin/sbt.bat @@ -547,6 +547,21 @@ if not "%g:~0,5%" == "-XX:+" if not "%g:~0,5%" == "-XX:-" if "%g:~0,3%" == "-XX" ) ) +if defined sbt_new if "%g:~0,2%" == "--" ( + rem special handling for -- template arguments since '=' gets parsed away on Windows + for /F "tokens=1 delims==" %%a in ("%g%") do ( + rem make sure it doesn't have the '=' already + if "%g%" == "%%a" ( + if not "%~1" == "" ( + call :dlog [args_loop] -- argument %~0=%~1 + set "SBT_ARGS=!SBT_ARGS! %~0=%~1" + shift + goto args_loop + ) + ) + ) +) + rem the %0 (instead of %~0) preserves original argument quoting set SBT_ARGS=!SBT_ARGS! %0 @@ -782,6 +797,18 @@ if not "%p:~0,5%" == "-XX:+" if not "%p:~0,5%" == "-XX:-" if "%p:~0,3%" == "-XX" ) ) +if defined sbt_new if "%p:~0,2%" == "--" ( + rem special handling for -- template arguments since '=' gets parsed away on Windows + for /F "tokens=1 delims==" %%a in ("%p%") do ( + rem make sure it doesn't have the '=' already + if "%p%" == "%%a" if not "%~1" == "" ( + echo %0=%1 + shift + goto echolist + ) + ) +) + if "%p:~0,14%" == "-agentlib:jdwp" ( rem special handling for --jvm-debug since '=' and ',' gets parsed away for /F "tokens=1 delims==" %%a in ("%p%") do (