]> Cypherpunks repositories - gostls13.git/commitdiff
{all,clean,make,race,run}.bat: use || instead of "if errorlevel 1"
authorqmuntal <quimmuntal@gmail.com>
Thu, 6 Feb 2025 09:55:59 +0000 (10:55 +0100)
committerQuim Muntal <quimmuntal@gmail.com>
Fri, 7 Feb 2025 17:13:54 +0000 (09:13 -0800)
"if errorlevel 1" is and old construct that returns true if the
errorlevel is greater than or equal to 1. There are better alternatives
since Windows NT. For example, the || operator runs the RHS operand if
the preceding command failed, determined by checking that the errorlevel
is different from 0. This approach is more robust -it also works with
negative errorlevels- and is less verbose.

Change-Id: I2070d654d8f9dd41a6cd586ba5ad5f4fea0638ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/647136
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
src/all.bat
src/clean.bat
src/make.bat
src/race.bat
src/run.bat

index 0c4d5de70c6cc0833d29b3201eff555fadf4045a..483151b8931dff49b0cca9835ea13f271ede75e4 100644 (file)
@@ -11,10 +11,8 @@ echo all.bat must be run from go\src
 exit /b 1\r
 :ok\r
 \r
-call .\make.bat --no-banner --no-local\r
-if errorlevel 1 goto fail\r
-call .\run.bat --no-rebuild\r
-if errorlevel 1 goto fail\r
+call .\make.bat --no-banner --no-local || goto fail\r
+call .\run.bat --no-rebuild || goto fail\r
 "%GOTOOLDIR%/dist" banner\r
 goto :eof\r
 \r
index ceba3a56cf44e89a4a5ca31332bc4420e1d0b441..51fa857b7c7ac7e251508c66e597e947a538705e 100644 (file)
@@ -6,8 +6,7 @@
 \r
 setlocal\r
 \r
-go tool dist env -w -p >env.bat\r
-if errorlevel 1 goto fail\r
+go tool dist env -w -p >env.bat || goto fail\r
 call .\env.bat\r
 del env.bat\r
 echo.\r
index 3a72a59470e565d8242e0e50eb0193927be29003..57e4e5f80cc9afb1b6df8f88ba20294fb48068d1 100644 (file)
@@ -101,11 +101,9 @@ echo Building Go cmd/dist using %GOROOT_BOOTSTRAP%. (%GOROOT_BOOTSTRAP_VERSION%)
 if x%vflag==x-v echo cmd/dist\r
 set GOROOT=%GOROOT_BOOTSTRAP%\r
 set GOBIN=\r
-"%GOROOT_BOOTSTRAP%\bin\go.exe" build -o cmd\dist\dist.exe .\cmd\dist\r
+"%GOROOT_BOOTSTRAP%\bin\go.exe" build -o cmd\dist\dist.exe .\cmd\dist || goto fail\r
 endlocal\r
-if errorlevel 1 goto fail\r
-.\cmd\dist\dist.exe env -w -p >env.bat\r
-if errorlevel 1 goto fail\r
+.\cmd\dist\dist.exe env -w -p >env.bat || goto fail\r
 call .\env.bat\r
 del env.bat\r
 if x%vflag==x-v echo.\r
@@ -148,8 +146,7 @@ if x%4==x--distpack set bootstrapflags=%bootstrapflags% -distpack
 :: Run dist bootstrap to complete make.bash.\r
 :: Bootstrap installs a proper cmd/dist, built with the new toolchain.\r
 :: Throw ours, built with the bootstrap toolchain, away after bootstrap.\r
-.\cmd\dist\dist.exe bootstrap -a %vflag% %bootstrapflags%\r
-if errorlevel 1 goto fail\r
+.\cmd\dist\dist.exe bootstrap -a %vflag% %bootstrapflags% || goto fail\r
 del .\cmd\dist\dist.exe\r
 goto :eof\r
 \r
index 64510b60129e9d9893ef025c3d5548790d595325..2f6ba914758ef8e327a2a0c4f855e12a5a6d6e36 100644 (file)
@@ -15,10 +15,8 @@ exit /b 1
 :ok\r
 \r
 set GOROOT=%CD%\..\r
-call .\make.bat --dist-tool >NUL\r
-if errorlevel 1 goto fail\r
-.\cmd\dist\dist.exe env -w -p >env.bat\r
-if errorlevel 1 goto fail\r
+call .\make.bat --dist-tool >NUL || goto fail\r
+.\cmd\dist\dist.exe env -w -p >env.bat || goto fail\r
 call .\env.bat\r
 del env.bat\r
 \r
@@ -27,15 +25,11 @@ echo Race detector is only supported on windows/amd64.
 goto fail\r
 \r
 :continue\r
-call .\make.bat --no-banner --no-local\r
-if errorlevel 1 goto fail\r
+call .\make.bat --no-banner --no-local || goto fail\r
 echo # go install -race std\r
-go install -race std\r
-if errorlevel 1 goto fail\r
+go install -race std || goto fail\r
+go tool dist test -race || goto fail\r
 \r
-go tool dist test -race\r
-\r
-if errorlevel 1 goto fail\r
 echo All tests passed.\r
 goto :eof\r
 \r
index 6a0ffe3af905ac6ac51b70be2bcbf5f9b33e652d..3e7b1a1b0c25b0fef1aa26e04ec1e60a9ec4f5c1 100644 (file)
@@ -12,14 +12,12 @@ goto fail
 setlocal\r
 \r
 set GOENV=off\r
-..\bin\go tool dist env > env.bat\r
-if errorlevel 1 goto fail\r
+..\bin\go tool dist env > env.bat || goto fail\r
 call .\env.bat\r
 del env.bat\r
 \r
 set GOPATH=c:\nonexist-gopath\r
-..\bin\go tool dist test --rebuild %*\r
-if errorlevel 1 goto fail\r
+..\bin\go tool dist test --rebuild %* || goto fail\r
 goto :eof\r
 \r
 :fail\r