Add support for more workspace boundary files to bash completion

Bash completion now also recognized `WORKSPACE.bazel`, `MODULE.bazel` and `REPO.bazel`.

Also fixes a shellcheck finding.

Closes #19268.

PiperOrigin-RevId: 557931944
Change-Id: Ia2b6e463f4643d9c0d829845fee4228103cf90a0
diff --git a/scripts/bash_completion_test.sh b/scripts/bash_completion_test.sh
index 50a808e..6a2f396 100755
--- a/scripts/bash_completion_test.sh
+++ b/scripts/bash_completion_test.sh
@@ -768,4 +768,30 @@
                      'info --show_make_env '
 }
 
+test_workspace_boundary() {
+    # "Test that workspace boundary files are recognized"
+    # this test only works for Bazel
+    if [[ ! " ${COMMAND_ALIASES[*]} " =~ " bazel " ]]; then return; fi
+
+    mkdir -p sub_repo/some/pkg
+    touch sub_repo/some/pkg/BUILD
+    cd sub_repo 2>/dev/null
+
+    touch WORKSPACE.bazel
+    assert_expansion 'build //s' \
+                     'build //some/'
+
+    mv WORKSPACE.bazel MODULE.bazel
+    assert_expansion 'build //s' \
+                     'build //some/'
+
+    mv MODULE.bazel REPO.bazel
+    assert_expansion 'build //s' \
+                     'build //some/'
+
+    rm REPO.bazel
+    assert_expansion 'build //s' \
+                     'build //sub_repo/'
+}
+
 run_suite "Tests of bash completion of 'blaze' command."