Skip to content

Commit f929602

Browse files
jurko-gospodneticvprus
authored andcommitted
Return valid exit code from Windows batch scripts.
Technique used for setting Windows batch script exit codes in Boost.Build worked correctly when the script is called from a Windows shell process and then checked from inside that process. However, when run from a temporary shell process that needs to terminate after running the script, such a process would always return exit code 0. This prevented anyone automating those scripts from detecting their success/ failure status by using their exit code without adding an additional batch script layer. For example, consider the following two script files: ret666.cmd: exit /b 666 wrapper.cmd: call ret666.cmd They both 'should return the value 666' and when run directly from a cmd.exe console indeed both do (they set the shell process's ERRORLEVEL environment variable to 666). However, when run like this: cmd /c <script-name> running ret666.cmd causes the temporary cmd.exe process to exit with exit code 666, while running wrapper.cmd causes it to exit with exit code 0.
1 parent 252b5aa commit f929602

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

bootstrap.bat

+1
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ ECHO.
4747
goto :end
4848

4949
:end
50+
exit /b %ERRORLEVEL%

src/engine/build.bat

+1
Original file line numberDiff line numberDiff line change
@@ -613,3 +613,4 @@ goto Set_Args
613613
:Skip_Jam
614614

615615
:Finish
616+
exit /b %ERRORLEVEL%

0 commit comments

Comments
 (0)