From c4aa9052b578ff6aa8ca1b92f5c058bcca5c3d2a Mon Sep 17 00:00:00 2001 From: Miranda Kastemaa Date: Mon, 17 Oct 2016 15:51:53 +0300 Subject: [PATCH] Use more reliable shift loop for processing args --- src/universal/bin/sbt.bat | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 5cf5fc7b7..27dd66d63 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -52,20 +52,25 @@ rem We use the value of the JAVA_OPTS environment variable if defined, rather th set _JAVA_OPTS=%JAVA_OPTS% if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%CFG_OPTS% -FOR %%a IN (%*) DO ( - if "%%a" == "-jvm-debug" ( - set JVM_DEBUG=true - set /a JVM_DEBUG_PORT=5005 2>nul >nul - ) else if "!JVM_DEBUG!" == "true" ( - set /a JVM_DEBUG_PORT=%%a 2>nul >nul - if not "%%a" == "!JVM_DEBUG_PORT!" ( - set SBT_ARGS=!SBT_ARGS! %%a - ) - ) else ( - set SBT_ARGS=!SBT_ARGS! %%a +:args_loop +if "%~1" == "" goto args_end + +if "%~1" == "-jvm-debug" ( + set JVM_DEBUG=true + set /a JVM_DEBUG_PORT=5005 2>nul >nul +) else if "!JVM_DEBUG!" == "true" ( + set /a JVM_DEBUG_PORT=%1 2>nul >nul + if not "%~1" == "!JVM_DEBUG_PORT!" ( + set SBT_ARGS=!SBT_ARGS! %1 ) +) else ( + set SBT_ARGS=!SBT_ARGS! %1 ) +shift +goto args_loop +:args_end + if defined JVM_DEBUG_PORT ( set _JAVA_OPTS=!_JAVA_OPTS! -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=!JVM_DEBUG_PORT! )