Bazel client: add and use blaze::GetPathEnv() Use GetPathEnv() instead of GetEnv() for envvars with paths. On Linux/macOS/POSIX, GetPathEnv and GetEnv do the same. On Windows, GetPathEnv removes the UNC prefix from the result, calls AsWindowsPath, then converts backslashes to forward slashes. (As callers expect the result.) Fixes https://github.com/bazelbuild/bazel/issues/7705 Closes #7707. PiperOrigin-RevId: 238236143
diff --git a/src/main/cpp/blaze_util_linux.cc b/src/main/cpp/blaze_util_linux.cc index a365ac9..e6e6d64 100644 --- a/src/main/cpp/blaze_util_linux.cc +++ b/src/main/cpp/blaze_util_linux.cc
@@ -130,7 +130,7 @@ } static string Which(const string &executable) { - string path(GetEnv("PATH")); + string path(GetPathEnv("PATH")); if (path.empty()) { return ""; } @@ -154,7 +154,7 @@ string GetSystemJavabase() { // if JAVA_HOME is defined, then use it as default. - string javahome = GetEnv("JAVA_HOME"); + string javahome = GetPathEnv("JAVA_HOME"); if (!javahome.empty()) { string javac = blaze_util::JoinPath(javahome, "bin/javac"); if (access(javac.c_str(), X_OK) == 0) {