Update the JAVAC_VERSION regex to handle the case where javac adds extra text around the version string. Fixes #1678.

--
Change-Id: I765699c43119e28d5f0ef8245b91e263d6af6dc0
Reviewed-on: https://bazel-review.googlesource.com/c/5570
MOS_MIGRATED_REVID=131080854
diff --git a/scripts/bootstrap/buildenv.sh b/scripts/bootstrap/buildenv.sh
index f97040f..610a218 100755
--- a/scripts/bootstrap/buildenv.sh
+++ b/scripts/bootstrap/buildenv.sh
@@ -157,7 +157,7 @@
     exitCode=1
   fi
   echo >&2
-  echo "$1" >&2
+  echo "$@" >&2
   exit $exitCode
 }
 
@@ -245,10 +245,12 @@
     || fail "JAVA_HOME ($JAVA_HOME) is not a path to a working JDK."
 
   JAVAC_VERSION=$("${JAVAC}" -version 2>&1)
-  if [[ "$JAVAC_VERSION" =~ ^"javac "(1\.([789]|[1-9][0-9])).*$ ]]; then
+  if [[ "$JAVAC_VERSION" =~ javac\ (1\.([789]|[1-9][0-9])).*$ ]]; then
     JAVAC_VERSION=${BASH_REMATCH[1]}
   else
-    fail "Cannot determine JDK version, please set \$JAVA_HOME."
+    fail \
+      "Cannot determine JDK version, please set \$JAVA_HOME.\n" \
+      "\$JAVAC_VERSION is \"${JAVAC_VERSION}\""
   fi
 }