Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0-JSR-3
-
None
-
None
-
win xp sp2, java 1.4.2_09
Description
Running groovy from within another script does not give the real exit value of the groovy process. Try any of the following:
perl -e "system('groovy -e \"System.exit(1)\"');print $?>>8"
ruby -e "system('groovy.bat -e \"System.exit(1)\"');print $?>>8"
groovy -e "p='groovy.bat -e \"System.exit(1)\"'.execute();p.waitFor();println p.exitValue()"
To see that the above examples are correct in catching the exit code, try e.g.
ruby -e "system('ruby -e \"exit(2)\"');print $?>>8"
groovy -e "def p='ruby -e \"exit(2)\"'.execute();;p.waitFor();println p.exitValue()"
Adding
exit %ERROR_LEVEL%
to the end of groovy.bat solves the problem but is not usable as it causes command prompt to exit if running groovy directly (i.e. not via some other script).