testenv.sh: Fix wrong path to bazelrc for shared repo caches.

PiperOrigin-RevId: 232195375
diff --git a/src/test/shell/testenv.sh b/src/test/shell/testenv.sh
index 872499d..80ddc95 100755
--- a/src/test/shell/testenv.sh
+++ b/src/test/shell/testenv.sh
@@ -287,9 +287,9 @@
 ${EXTRA_BAZELRC:-}
 EOF
 
-  if [[ -d ${REPOSITORY_CACHE:-} ]]; then
+  if [[ -n ${REPOSITORY_CACHE:-} ]]; then
     echo "testenv.sh: Using repository cache at $REPOSITORY_CACHE."
-    cat >>$TEST_TMPDIR <<EOF
+    cat >>$TEST_TMPDIR/bazelrc <<EOF
 sync --repository_cache=$REPOSITORY_CACHE --experimental_repository_cache_hardlinks
 fetch --repository_cache=$REPOSITORY_CACHE --experimental_repository_cache_hardlinks
 build --repository_cache=$REPOSITORY_CACHE --experimental_repository_cache_hardlinks
@@ -297,7 +297,7 @@
 EOF
   fi
 
-  if [[ -d ${INSTALL_BASE:-} ]]; then
+  if [[ -n ${INSTALL_BASE:-} ]]; then
     echo "testenv.sh: Using shared install base at $INSTALL_BASE."
     echo "startup --install_base=$INSTALL_BASE" >> $TEST_TMPDIR/bazelrc
   fi