Windows: fix bootstrapping bugs with 0.4.4 

Fix 3 bugs to get bootstrapping working on Windows
after it was broken in bazel-0.4.4:

* Move the definition of PATHSEP to before the
code that overrides it for Windows

* Fix the Java code processing the --javahome flag
to recognize absolute Windows paths as absolute.
See: https://github.com/bazelbuild/bazel/issues/2520

* Do not propagate the JAVA_HOME value in
variables, because it contains spaces on Windows,
and when we pass the variable to Bazel, and it's
expanded to e.g. ... --foo=C:/Program Files,
these are interpreted as two args instead of one.

Also fix a bug that is just annoying, not causing
any trouble (on Windows):

* Silently swallow errors from the "rm -rf" in the
atexit functions

Also do some refactoring:

* Rename a variable (BAZEL_ARGS) and a method to
indicate they're private. They are not used from
anywhere else as far as I know -- no occurrences
in either the bazel or the continuous-integration
repos.

Fixes: https://github.com/bazelbuild/bazel/issues/2473

--
Change-Id: I309752cd7bbff0b5dd683ddb5573f3061350043c
Reviewed-on: https://cr.bazel.build/8797
PiperOrigin-RevId: 147345194
MOS_MIGRATED_REVID=147345194
diff --git a/scripts/bootstrap/buildenv.sh b/scripts/bootstrap/buildenv.sh
index 62ebc11..39a15c4 100755
--- a/scripts/bootstrap/buildenv.sh
+++ b/scripts/bootstrap/buildenv.sh
@@ -58,6 +58,7 @@
   MACHINE_IS_64BIT='yes'
 fi
 
+PATHSEP=":"
 case "${PLATFORM}" in
 linux)
   # JAVA_HOME must point to a Java installation.
@@ -82,6 +83,8 @@
   PATHSEP=";"
   # Find the latest available version of the SDK.
   JAVA_HOME="${JAVA_HOME:-$(ls -d /c/Program\ Files/Java/jdk* | sort | tail -n 1)}"
+  # Replace backslashes with forward slashes.
+  JAVA_HOME="${JAVA_HOME//\\//}"
 esac
 
 EXE_EXT=""
@@ -150,7 +153,7 @@
   local DIR="$(mktemp -d "${tmp%%/}/bazel_XXXXXXXX")"
   mkdir -p "${DIR}"
   local DIRBASE=$(basename "${DIR}")
-  eval "cleanup_tempdir_${DIRBASE}() { rm -rf '${DIR}'; }"
+  eval "cleanup_tempdir_${DIRBASE}() { rm -rf '${DIR}' >&/dev/null || true ; }"
   atexit cleanup_tempdir_${DIRBASE}
   NEW_TMPDIR="${DIR}"
 }