Xalanj 2821 (#12)

Clean up the builds to return error codes/result codes, for use when
build is invoked programmatically rather than from command line. Should
be much cleaner than trying to parse the console output.

Co-authored-by: kubycsolutions <keshlam@kubyc.solutions>
diff --git a/build.bat b/build.bat
index 30f8294..a2db77c 100644
--- a/build.bat
+++ b/build.bat
@@ -28,6 +28,9 @@
 rem
 rem        2) You can set ANT_HOME if you use your own Ant install
 
+rem Upon exit, revert any environment variable changes
+setlocal
+
 echo.
 echo Xalan-J test automation build
 echo -----------------------------
@@ -64,14 +67,13 @@
 @echo on
 "%_JAVACMD%" -mx1024m -Djava.endorsed.dirs=%XALAN_BUILD_DIR_PATH%;%XERCES_ENDORSED_DIR_PATH% -classpath "%_CLASSPATH%" org.apache.tools.ant.Main %ANT_CMD_LINE_ARGS%
 @echo off
+set _RC=%ERRORLEVEL%
 
 goto end
 
 :noJavaHome
 echo Warning: JAVA_HOME environment variable is not set
+set _RC=-1
 
 :end
-set _CLASSPATH=
-set _ANT_HOME=
-set _JAVACMD=
-set _ANT_JARS=
\ No newline at end of file
+exit /b %_RC%
diff --git a/build.sh b/build.sh
index 8f6c3a4..bf7bcb8 100755
--- a/build.sh
+++ b/build.sh
@@ -92,4 +92,6 @@
 echo Running: "$JAVACMD" -mx1024m -Djava.endorsed.dirs="$XALAN_BUILD_DIR_PATH:$XERCES_ENDORSED_DIR_PATH" -classpath "$CLASSPATH" org.apache.tools.ant.Main "$@"
 "$JAVACMD" -mx1024m -Djava.endorsed.dirs="$XALAN_BUILD_DIR_PATH:$XERCES_ENDORSED_DIR_PATH" -classpath "$CLASSPATH" org.apache.tools.ant.Main "$@"
 
-echo "build.sh complete!"
+ant_rc=$?
+echo "build.sh complete with return code" $ant_rc
+exit $ant_rc