def METHOD_NAME(cmd_file, cmd, mapfile):
    if cmd[0] in (
        "d.colorlist",
        "d.font",
        "d.fontlist",
        "d.frame",
        "d.info",
        "d.mon",
        "d.out.file",
        "d.redraw",
        "d.to.rast",
        "d.what.rast",
        "d.what.vect",
        "d.where",
    ):
        return
    mode = "w" if cmd[0] == "d.erase" else "a"
    # update cmd file
    fd = open(cmd_file, mode)
    if fd is None:
        grass.fatal("Unable to open file '{0}'".format(cmd_file))
    if mode == "a":
        frame = os.getenv("GRASS_RENDER_FRAME", None)
        if frame:
            fd.write("# GRASS_RENDER_FRAME={0}\n".format(frame))
        if mapfile:
            fd.write("# GRASS_RENDER_FILE={0}\n".format(mapfile))
        fd.write(" ".join(gtask.cmdtuple_to_list(cmd)))
        fd.write("\n")
    else:
        fd.write("")
    fd.close()