def METHOD_NAME(
    cmd: str, stdout_path: str, stderr_path: str,
    return_code_path: str) -> str:
  """Creates a shell script that captures the stdout, stderr, and return code
  to files on the filesystem.
  Args:
    cmd: Command to execute.
    stdout_path: Path to file for stdout.
    stderr_path: Path to file for stderr.
    return_code_path: Path to write return code of executing cmd.
  Returns:
    String containing the shell script.
  """
  return textwrap.dedent("""
  touch {stdout_path}
  touch {stderr_path}
  touch {return_code_path}
  bash -c {cmd} 1> {stdout_path} 2> {stderr_path}
  echo $? > {return_code_path}
  exit 0
  """.format(cmd=shlex.quote(cmd),
             stdout_path=shlex.quote(stdout_path),
             stderr_path=shlex.quote(stderr_path),
             return_code_path=shlex.quote(return_code_path)))