Replace BuildConfiguration.Fragment#collectExecutables() with a #getShellExecutable() method.

That's all it was used for anyway.

--
MOS_MIGRATED_REVID=133824769
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/CommandHelper.java b/src/main/java/com/google/devtools/build/lib/analysis/CommandHelper.java
index 1890486..eb4208a 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/CommandHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/CommandHelper.java
@@ -306,6 +306,6 @@
   private PathFragment shellPath(Map<String, String> executionInfo) {
     // Use vanilla /bin/bash for actions running on mac machines.
     return executionInfo.containsKey("requires-darwin")
-        ? new PathFragment("/bin/bash") : ruleContext.getConfiguration().getShExecutable();
+        ? new PathFragment("/bin/bash") : ruleContext.getConfiguration().getShellExecutable();
   }
 }
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java
index 6e34e0f..988e1d8 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java
@@ -568,7 +568,7 @@
       Iterable<String> arguments = argumentsBuilder.build();
       // Check to see if we need to use param file.
       Artifact paramsFile = ParamFileHelper.getParamsFileMaybe(
-          buildExecutableArgs(configuration.getShExecutable()),
+          buildExecutableArgs(configuration.getShellExecutable()),
           arguments,
           commandLine,
           paramFileInfo,
@@ -589,7 +589,7 @@
           buildSpawnAction(
               owner,
               configuration.getLocalShellEnvironment(),
-              configuration.getShExecutable(),
+              configuration.getShellExecutable(),
               paramsFile,
               paramFileWriteAction));
       if (paramFileWriteAction != null) {
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
index 272582d..8f01d0d 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java
@@ -198,11 +198,13 @@
     }
 
     /**
-     * Add mappings from generally available tool names (like "sh") to their paths
-     * that actions can access.
+     * Returns the shell to be used.
+     *
+     * <p>Each configuration instance must have at most one fragment that returns non-null.
      */
     @SuppressWarnings("unused")
-    public void defineExecutables(ImmutableMap.Builder<String, PathFragment> builder) {
+    public PathFragment getShellExecutable() {
+      return null;
     }
 
     /**
@@ -1065,7 +1067,7 @@
   private final boolean actionsEnabled;
 
   // TODO(bazel-team): Move this to a configuration fragment.
-  private final PathFragment shExecutable;
+  private final PathFragment shellExecutable;
 
   /**
    * The global "make variables" such as "$(TARGET_CPU)"; these get applied to all rules analyzed in
@@ -1285,7 +1287,7 @@
         ? options.outputDirectoryName : mnemonic;
     this.platformName = buildPlatformName();
 
-    this.shExecutable = collectExecutables().get("sh");
+    this.shellExecutable = computeShellExecutable();
 
     this.outputRoots = outputRoots != null
         ? outputRoots
@@ -2066,8 +2068,8 @@
   /**
    * Returns the path to sh.
    */
-  public PathFragment getShExecutable() {
-    return shExecutable;
+  public PathFragment getShellExecutable() {
+    return shellExecutable;
   }
 
   /**
@@ -2366,12 +2368,17 @@
   /**
    * Collects executables defined by fragments.
    */
-  private ImmutableMap<String, PathFragment> collectExecutables() {
-    ImmutableMap.Builder<String, PathFragment> builder = new ImmutableMap.Builder<>();
+  private PathFragment computeShellExecutable() {
+    PathFragment result = null;
+
     for (Fragment fragment : fragments.values()) {
-      fragment.defineExecutables(builder);
+      if (fragment.getShellExecutable() != null) {
+        Verify.verify(result == null);
+        result = fragment.getShellExecutable();
+      }
     }
-    return builder.build();
+
+    return result;
   }
 
   /**