private String getFormattedCommand(String logDirExpansionVar, String command, String stdOut, String stdErr) {
    return String.format("export SAMZA_LOG_DIR=%s && ln -sfn %s logs && exec %s 1>logs/%s 2>logs/%s",
        logDirExpansionVar, logDirExpansionVar, command, stdOut, stdErr);
  }
Gets the environment variables from the specified {@link CommandBuilder} and escapes certain characters.

@param cmdBuilder        the command builder containing the environment variables.
@return                  the map containing the escaped environment variables.
samza-yarn/src/main/java/org/apache/samza/job/yarn/YarnClusterResourceManager.java