Skip to main content

Module env

Module env 

Source
Expand description

Explicit caller-owned foreground command execution. The mechanism for reading declared environment variables (#1101).

This is how a variable is read – the kinds, the owner, the typed accessors and the boolean parsers – with no variable names in it. It lives here, below running-process, so every crate in the workspace can share one parser instead of growing its own; running_process::env_vars re-exports it and keeps the policy: which variables exist, and what each means.

§Why booleans get two accessors rather than one

“Is this switch on?” has two defensible answers when the value is neither clearly on nor clearly off, and which one is right depends on who owns the variable – not on the call site, which is how a codebase ends up with five parsers that disagree.

  • flag_owned is for switches the reader defines. Unknown means off.
  • flag_foreign is for values written by someone else. Unknown means on, so a stray =0 cannot exempt a process from being reaped.
  • flag_opt_out is for an escape hatch that is on until someone turns it off. Unset means on.

All three trim and lowercase before comparing, so " True " and "TRUE" agree.

Structs§

EnvVar
One environment variable the reader reads.

Enums§

EnvKind
What kind of value a variable carries, and how it is read.
Owner
Who decides what values a variable may take.

Functions§

flag_foreign
Read a switch someone else writes: off only for a recognised negative.
flag_opt_out
Read an escape hatch that is on unless turned off.
flag_owned
Read a switch the reader owns: on only for a recognised affirmative.
os_named
Read a variable whose name is caller-supplied data, exactly as the host wrote it.
string_named
os_named as Unicode: None when unset or not valid Unicode, matching std::env::var.
value_is_affirmative_foreign
Whether a value already in hand reads as a foreign switch being on.