From: 0x2b3bfa0 <0x2b3bfa0+git@googlemail.com> Date: Fri, 28 Feb 2025 09:05:52 +0000 (+0100) Subject: make.bat: fix GOROOT_BOOTSTRAP detection X-Git-Tag: go1.25rc1~555 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9326d9d01231a1834458810c3cb01701bf7293a9;p=gostls13.git make.bat: fix GOROOT_BOOTSTRAP detection Due to a flaw in the %GOROOT_BOOTSTRAP% detection logic, the last Go executable found by `where go` was taking precedence over the first one. In batch scripts, environment variable expansion happens when each line of the script is read, not when it is executed. Thus, the check in the loop for GOROOT_BOOTSTRAP being unset would always be true, even when the variable had been set in a previous loop iteration. See SET /? for more information. Change-Id: I15ddcbe771a902acb47a1f07ba7f4cb8a311e0dc Reviewed-on: https://go-review.googlesource.com/c/go/+/653535 Auto-Submit: Carlos Amedee Reviewed-by: Carlos Amedee Reviewed-by: Quim Muntal Reviewed-by: Dmitri Shuralyov LUCI-TryBot-Result: Go LUCI --- diff --git a/src/make.bat b/src/make.bat index 6c683230ce..d9f686452e 100644 --- a/src/make.bat +++ b/src/make.bat @@ -60,14 +60,13 @@ if not exist ..\bin\tool mkdir ..\bin\tool :: Calculating GOROOT_BOOTSTRAP if not "x%GOROOT_BOOTSTRAP%"=="x" goto bootstrapset for /f "tokens=*" %%g in ('where go 2^>nul') do ( - if "x%GOROOT_BOOTSTRAP%"=="x" ( - setlocal - call :nogoenv - for /f "tokens=*" %%i in ('"%%g" env GOROOT 2^>nul') do ( - endlocal - if /I not "%%i"=="%GOROOT_TEMP%" ( - set GOROOT_BOOTSTRAP=%%i - ) + setlocal + call :nogoenv + for /f "tokens=*" %%i in ('"%%g" env GOROOT 2^>nul') do ( + endlocal + if /I not "%%i"=="%GOROOT_TEMP%" ( + set GOROOT_BOOTSTRAP=%%i + goto bootstrapset ) ) )