Allow propagation of execution requirements to the ctx.resolve_command function. In the case of the requires-darwin tag, /bin/bash will be used instead
of an alternative, which matches the current genrule implementation.

--
MOS_MIGRATED_REVID=114360408
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 b2523de..6dfd5e5 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
@@ -273,11 +273,9 @@
   public List<String> buildCommandLine(
       String command, NestedSetBuilder<Artifact> inputs, String scriptPostFix,
       Map<String, String> executionInfo) {
-    // Use vanilla /bin/bash for actions running on mac machines.
-    PathFragment shellPath = executionInfo.containsKey("requires-darwin")
-        ? new PathFragment("/bin/bash") : ruleContext.getConfiguration().getShExecutable();
     Pair<List<String>, Artifact> argvAndScriptFile =
-        buildCommandLineMaybeWithScriptFile(ruleContext, command, scriptPostFix, shellPath);
+        buildCommandLineMaybeWithScriptFile(ruleContext, command, scriptPostFix,
+            shellPath(executionInfo));
     if (argvAndScriptFile.second != null) {
       inputs.add(argvAndScriptFile.second);
     }
@@ -290,12 +288,22 @@
    * Fixes up the input artifact list with the created bash script when required.
    */
   public List<String> buildCommandLine(
-      String command, List<Artifact> inputs, String scriptPostFix) {
+      String command, List<Artifact> inputs, String scriptPostFix,
+      Map<String, String> executionInfo) {
     Pair<List<String>, Artifact> argvAndScriptFile = buildCommandLineMaybeWithScriptFile(
-        ruleContext, command, scriptPostFix, ruleContext.getConfiguration().getShExecutable());
+        ruleContext, command, scriptPostFix, shellPath(executionInfo));
     if (argvAndScriptFile.second != null) {
       inputs.add(argvAndScriptFile.second);
     }
     return argvAndScriptFile.first;
   }
+
+  /**
+   * Returns the path to the shell for an action with the given execution requirements.
+   */
+  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();
+  }
 }