Skip to main content

Module lookup

Module lookup 

Source
Expand description

Program lookup through an environment’s PATH.

A program name without / is looked up in the PATH of the environment that the program gets: for a step, the task environment, never kizz’s own; for kizz execute, the caller’s. Each directory of PATH is tried in order, as execvp does: an empty entry means the working directory, and a relative entry resolves against it. Every location checked is reported as a probe, so it becomes a dependency of the step and a program that appears earlier in PATH re-runs the step. The first location that holds a regular file with an execute bit is the program.

A program name with / is not looked up: it resolves against the working directory, and the tracer reports whether it can be run.

search_program is the lookup itself, for any name and PATH of bytes, and reports each checked location with its outcome: ok when something is there, and otherwise the name of the error, which it gets from the caller, such as the tracer’s error-name query (kizz_trace::Tracer::error_name). find_program is the lookup of run(), for a task environment of strings, with the checked locations as accesses; search_step_program is the same lookup with each checked location’s outcome, for the report of kizz run --output. check_path is the check that such a lookup can be made at all, from the program name and the environment alone, which the engine makes before the cache check.

Structs§

NoPathError
A bare program name in a task environment without PATH.

Enums§

ProgramLookup
The result of looking up a program.
ProgramSearch
The result of search_program: the result of a lookup, with every location that it checked as a probe with its outcome.

Constants§

PATH_VARIABLE
The variable that lists the directories to search for programs.

Functions§

check_path
Check that the program name of a step whose environment is env can be looked up: a name with / needs no lookup, and any other name needs a PATH in env. The check reads only these two values, so it gives the same answer every time, as search_step_program does for a missing PATH.
find_program
Look up the program name for a step whose environment is env and whose working directory is cwd, with search_program.
search_program
Look up the program name in search, the value of PATH, or None when the environment has no PATH, for a program whose working directory is cwd. Each checked location is a probe whose outcome is ok when something is there, and otherwise the name that error_name gives the error number of the failed check, or unknown when the failure has no number.
search_step_program
Look up the program name for a step whose environment is env and whose working directory is cwd, as find_program does, keeping the outcome of each checked location, whose error error_name names, for the observation report of kizz run --output.