@echo off
if "%1" == "ifexitnob" (
echo into if, exit without /b
pushd subfolder
exit 1
popd
)
if "%1" == "ifexitb" (
echo into if, exit /b
pushd subfolder
exit /b 1
popd
)
put above script into a script.bat file, then call it from build-wrapper and print ERRORLEVEL.
build-wrapper-win-x86-64.exe --out-dir test script.bat ifexitnob
echo %ERRORLEVEL% --> Will show 1, OK
build-wrapper-win-x86-64.exe --out-dir test script.bat ifexitb
echo %ERRORLEVEL% --> Will show 0, KO
potential workaround
Do not use /b option of exit command, although it is common practice for Windows Batch scripting
what version of the build-wrapper are you using? Could you please share the build-wrapper output dir that you named test? We had this bug and it has been fixed 4 years ago, see CPP-1372.
@echo off
mkdir subfolder 2> nul
pushd subfolder
if "%1" == "ifexitb" (
echo into if, exit /b
exit /b 1
popd
)
if "%1" == "ifexitnob" (
echo into if, exit without /b
exit 1
popd
)
Issue seems related to underlying cmd.exe call strange behavior.
Probably above script can replicate the issue on your side.
If it is the case, try removing the popd statement at line 7, and now it works fine…
C:\WINDOWS\system32\cmd.exe /c script.bat ifexitnob
echo %ERRORLEVEL% --> Will show 1, OK
C:\WINDOWS\system32\cmd.exe /c script.bat ifexitb
echo %ERRORLEVEL% --> Will show 0, KO
So it is probably not a build-wrapper issue
Edit: not reproducible on all our machines, so this is not an issue to spend much time on. Just applying the workaround.