Summary: | proper retrncode for ant.bat | ||
---|---|---|---|
Product: | Ant | Reporter: | Martin Bluemel <martin.bluemel> |
Component: | Wrapper scripts | Assignee: | Ant Notifications List <notifications> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | ahengle, martin.bluemel, scottstirling, sfllaw, sommerlade |
Priority: | P3 | ||
Version: | 1.6.5 | ||
Target Milestone: | 1.7.0 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Attachments: |
Portable error handling for ant.bat
Updated portable error handling patch against ant/src/script/ant.bat 1.32 updated ant.bat with proper errorlevel exit |
Description
Martin Bluemel
2002-10-15 15:56:35 UTC
Trouble is we have to support the win9x platform too, and they cant handle return codes properly, which is why the .bat file doesnt do it. I always recommend using the perl invoker from things like makefiles as it is consistent with return codes across all boxes (that need perl installed, of course). So, your patch looks like it works for you, but I dont think we could pull it in to the main codebase. Indeed, the batch and .sh files create such an inordinate amount of support calls we like to avoid touching them whenever they seem stable. Created attachment 5022 [details]
Portable error handling for ant.bat
I have run into the exact same problem. I also have a patch to ant/src/script/ant.bat that is more useful. It applies to CVS HEAD (currently 1.18.2.8) and has been tested to work on Windows 95, Windows NT 4 SP 6, Windows 2000 and Windows XP. Changelog: * src/script/ant.bat: Detects build failures and throws errors. It throws ERRORLEVEL 1, and stores Ant's return code in %ANT_ERROR%. * src/script/ant.bat: Removed extraneous label. Created attachment 7911 [details]
Updated portable error handling patch against ant/src/script/ant.bat 1.32
This bug makes ant on windows useless in automatic build systems, and this buggy behaviour at least deserves a proper hint/warning somewhere in the documentation. Created attachment 13849 [details]
updated ant.bat with proper errorlevel exit
The other solutions seem overly complicated and set a random variable
"ANT_ERROR". The proper way to exit a batch file with an error code is to use
exit /b #. This works in win2k but not sure about 98.
This still seems to be a bug in Ant 1.6.5. The fix is easy. Anthill doesn't work without it. Not sure what other impact it may have. Vote for this bug. Vince, the exit command doesn't take any options in Windows 9x nor NT4. My solution, unfortunately, is the most useful one. Trust me, I had no desire to write something as ugly as my patch. But portable error handling across Windows batch scripts is non-trivial. I no longer have any use for Ant on Windows, so I can't update my patch. But I'm sure that someone can figure out what's going on and port it to the most recent version in CVS. |