pub struct SpawnEnv {
pub overrides: Vec<(String, String)>,
pub cwd: Option<String>,
}Expand description
A typed env + cwd override an embedder stamps on every child PTY.
Applied by the spawn backend AFTER the inherited + fallback env, so
each (key, value) here OVERRIDES whatever the backend defaulted.
Serialize/Deserialize so a tear-client can push the override
across the daemon wire (Request::SetSpawnEnv) — closing the gap
where the daemon-spawned child only saw the daemon’s own env, never
the embedder’s capability projection (truecolor/terminfo).
Fields§
§overrides: Vec<(String, String)>Env pairs that override the backend’s inherited/fallback env.
Order is preserved; later duplicates win (the backend’s env
vec is a positional list CommandBuilder walks in order).
cwd: Option<String>Working directory for the child. When Some, the spawn backend
also stamps PWD=<dir> so a child shell’s $PWD matches its
real cwd (the cwd-handshake hygiene). None leaves the
backend’s cwd untouched.
Implementations§
Source§impl SpawnEnv
impl SpawnEnv
Sourcepub fn none() -> Self
pub fn none() -> Self
An empty override — the backend’s inherited + fallback env is used verbatim (the pre-seam behaviour).
Sourcepub fn from_overrides(overrides: Vec<(String, String)>) -> Self
pub fn from_overrides(overrides: Vec<(String, String)>) -> Self
Build from typed env pairs (the embedder’s capability projection) with no cwd override.
Sourcepub fn with_cwd(self, cwd: Option<String>) -> Self
pub fn with_cwd(self, cwd: Option<String>) -> Self
Set the working directory the child spawns in (and the PWD
the backend stamps to match it).
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether this override carries anything — an empty override lets the backend skip the apply pass entirely.
Sourcepub fn apply_to(&self, env: &mut Vec<(String, String)>)
pub fn apply_to(&self, env: &mut Vec<(String, String)>)
Apply this override onto a backend-built env vec IN PLACE:
every override key replaces an existing entry (or pushes a new
one), then PWD is reconciled with the cwd — stamped when a
cwd is set, removed when it is not, so a child can never inherit
a stale parent PWD. This is the ONE place the apply order is
defined; both the in-process and daemon backends call it.