code: private static List<String> prepareBashCommand(List<String> cmd, Map<String, String> childEnv) {
      if (childEnv.isEmpty()) {
        return cmd;
      }
  
      List<String> newCmd = new ArrayList<>();
      newCmd.add("env");
  
      for (Map.Entry<String, String> e : childEnv.entrySet()) {
        newCmd.add(String.format("%s=%s", e.getKey(), e.getValue()));
      }
      newCmd.addAll(cmd);
      return newCmd;
    }
docs: Prepare the command for execution from a bash script. The final command will have commands to
  set up any needed environment variables needed by the child process.