]> Cypherpunks repositories - gostls13.git/commitdiff
make.bat: fix GOROOT_BOOTSTRAP detection
author0x2b3bfa0 <0x2b3bfa0+git@googlemail.com>
Fri, 28 Feb 2025 09:05:52 +0000 (10:05 +0100)
committerGopher Robot <gobot@golang.org>
Thu, 3 Apr 2025 15:45:30 +0000 (08:45 -0700)
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 <carlos@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/make.bat

index 6c683230ce17146caf0f56bd96ff4716b971f365..d9f686452e89748cf11f89b1761f1272fd74b2d3 100644 (file)
@@ -60,14 +60,13 @@ if not exist ..\bin\tool mkdir ..\bin\tool
 :: Calculating GOROOT_BOOTSTRAP\r
 if not "x%GOROOT_BOOTSTRAP%"=="x" goto bootstrapset\r
 for /f "tokens=*" %%g in ('where go 2^>nul') do (\r
-       if "x%GOROOT_BOOTSTRAP%"=="x" (\r
-               setlocal\r
-               call :nogoenv\r
-               for /f "tokens=*" %%i in ('"%%g" env GOROOT 2^>nul') do (\r
-                       endlocal\r
-                       if /I not "%%i"=="%GOROOT_TEMP%" (\r
-                               set GOROOT_BOOTSTRAP=%%i\r
-                       )\r
+       setlocal\r
+       call :nogoenv\r
+       for /f "tokens=*" %%i in ('"%%g" env GOROOT 2^>nul') do (\r
+               endlocal\r
+               if /I not "%%i"=="%GOROOT_TEMP%" (\r
+                       set GOROOT_BOOTSTRAP=%%i\r
+                       goto bootstrapset\r
                )\r
        )\r
 )\r