From 59e0d56e7706a19890ce5dc91ea4196ed5a9c058 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 9 Aug 2019 13:02:37 +0200 Subject: build: fix batch file status returning Apparently, exit /b works only halfway in Windows 8 and later. The %errorlevel% is correct after batch exits, but && and || do not honor it. The `cmd /c exit` doesn't actually quit the batch processing, therefore it must be at the very end of the batch file. Even `goto :eof` resets the return status for && and ||. Source: https://www.computerhope.com/forum/index.php/topic,65815.msg920454.html#msg920454 Signed-off-by: Simon Rozman --- build.bat | 8 ++++---- installer/build.bat | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build.bat b/build.bat index f6a5d304..aa82f584 100644 --- a/build.bat +++ b/build.bat @@ -52,10 +52,6 @@ if exist .deps\prepared goto :render echo [+] Success. Launch wireguard.exe. exit /b 0 -:error - echo [-] Failed with error #%errorlevel%. - exit /b %errorlevel% - :download echo [+] Downloading %1 curl -#fLo %1 %2 || exit /b 1 @@ -83,3 +79,7 @@ if exist .deps\prepared goto :render move /Y .deps\src\tools\wg.exe "%~1\wg.exe" > NUL || exit /b 1 ) goto :eof + +:error + echo [-] Failed with error #%errorlevel%. + cmd /c exit %errorlevel% diff --git a/installer/build.bat b/installer/build.bat index 295ce437..8d438af9 100644 --- a/installer/build.bat +++ b/installer/build.bat @@ -47,10 +47,6 @@ if exist .deps\prepared goto :build echo [+] Success. exit /b 0 -:error - echo [-] Failed with error #%errorlevel%. - exit /b %errorlevel% - :download echo [+] Downloading %1 curl -#fLo %1 %2 || exit /b 1 @@ -72,3 +68,7 @@ if exist .deps\prepared goto :build echo [+] Linking %1 "%WIX%bin\light" %WIX_LIGHT_FLAGS% -out "dist\wireguard-%~1-%WIREGUARD_VERSION%.msi" "%~1\wireguard.wixobj" || exit /b %errorlevel% goto :eof + +:error + echo [-] Failed with error #%errorlevel%. + cmd /c exit %errorlevel% -- cgit v1.2.3-59-g8ed1b