[Mono-list] Windows: Propagating exit codes in .bat files?
Mon, 03 May 2004 01:10:27 +0530
On Sun, 2004-05-02 at 23:53, Miguel de Icaza wrote:
> Hey guys,
> We have an issue with Mono, we are shipping batch files for Windows
> like this:
> c:\>type mcs.bat
> mono mcs.exe
> The problem is that if `mcs.exe' returns an exitcode different than
> zero, the error is not propagated to the caller, so this means that in
> Makefiles, things keep going even if there is a failure.
The exit code is updated in an environment variable called ERRORLEVEL.
Inside the batch file, you can test ERRORLEVEL values with IF (please
check help page). However, the comparison has to be in a sequence of
larger-to-smaller values. That is, if an app can return either of 101,
56, 1 and 0, then the check has to be done first for 101, then for 56
and so on.
Hope this helps.