Answer stability round 1: 0 🔴, 3 🟡 (0 misread); drop the duplicate predicate test, say that finds_this_docker assumes run-heavy's PATH, say why resets_path matches broadly
This commit is contained in:
@@ -37,10 +37,10 @@ def without_path_entry(path: str) -> str:
|
||||
|
||||
|
||||
def finds_this_docker(word: str, before: list[str]) -> bool:
|
||||
"""Whether a command that runs under run-heavy reaches this docker, given the word that names docker and the words before it: docker named bare, since a path names another, and no word before it resets the PATH that run-heavy set. Only where run-heavy knows the memory, as on Linux."""
|
||||
"""Whether a command's docker is this one, given the word that names docker and the words before it, assuming run-heavy put this docker first on PATH, as it does on Linux. It is where docker is named bare, since a path names a different docker, and no word before it may reset PATH."""
|
||||
return word == "docker" and not any(resets_path(earlier) for earlier in before)
|
||||
|
||||
|
||||
def resets_path(word: str) -> bool:
|
||||
"""Whether a word before docker drops the PATH run-heavy set: a PATH= of its own, env's -i or -u, or sudo or doas, which reset it."""
|
||||
"""Whether a word before docker may drop the PATH run-heavy set. It errs towards yes, so that a command it matches must set its own memory limits: it matches a PATH= assignment, -i, --ignore-environment, -u or --unset whichever variable and launcher they belong to, and sudo or doas, which reset PATH."""
|
||||
return word.startswith(("PATH=", "--unset")) or word in ("-i", "--ignore-environment", "-u") or tool_name(word) in ("doas", "sudo")
|
||||
|
||||
Reference in New Issue
Block a user