def METHOD_NAME(cmd: list[str], preserve_env: list[str] | None = None) -> list[str]:
    if RunningAsRoot()():
        return cmd
    if PikaurConfig().misc.PrivilegeEscalationTool.get_str() == "doas":
        return [PikaurConfig().misc.PrivilegeEscalationTool.get_str(), *cmd]
    result = [PikaurConfig().misc.PrivilegeEscalationTool.get_str()]
    if preserve_env:
        result.append("--preserve-env=" + ",".join(preserve_env))
    result += ["--", *cmd]
    return result