fix: Add defensive checks in --version handler to prevent Windows hangs (#8717)

Add 'if defined' checks before using variables to ensure they're set
before accessing them. This should prevent hangs caused by accessing
uninitialized variables in delayed expansion context.
This commit is contained in:
Eruis2579 2026-02-10 22:41:29 +01:00
parent 2d26055de0
commit 6232500286
1 changed files with 16 additions and 9 deletions

View File

@ -618,17 +618,24 @@ if !sbt_args_print_sbt_script_version! equ 1 (
)
rem Handle --version before native client so it works on sbt 2.x project dirs (#8717)
if !sbt_args_print_version! equ 1 (
if !is_this_dir_sbt! equ 1 (
if not "!build_props_sbt_version!" == "" (
echo sbt version in this project: !build_props_sbt_version!
rem Only handle if explicitly requested to avoid interfering with normal execution
if defined sbt_args_print_version (
if "!sbt_args_print_version!" == "1" (
if defined is_this_dir_sbt (
if "!is_this_dir_sbt!" == "1" (
if defined build_props_sbt_version (
if not "!build_props_sbt_version!" == "" (
echo sbt version in this project: !build_props_sbt_version!
)
)
)
)
echo sbt runner version: !init_sbt_version!
echo.
echo [info] sbt runner (sbt-the-batch-script) is a runner to run any declared version of sbt.
echo [info] Actual version of the sbt is declared using project\build.properties for each build.
goto :eof
)
echo sbt runner version: !init_sbt_version!
echo.
echo [info] sbt runner (sbt-the-batch-script) is a runner to run any declared version of sbt.
echo [info] Actual version of the sbt is declared using project\build.properties for each build.
exit /B 0
)
if !run_native_client! equ 1 (