Expand description
The process environment, read once.
Everything the game needs to know about the process it runs in is gathered here, in main,
and passed down: the home directory, the user name, the working directory, where the state
lives, whether the binary runs inside the game shell, and a few knobs that tests and
developers use. No game logic reads std::env or the process working directory after this, so
every rule below this layer is a plain function of its inputs and tests never chdir or
set_var.
| variable | field | meaning |
|---|---|---|
HOME | Env::home | the logical home directory |
USER | Env::user | the player’s name (player when unset) |
SHELLGAME_STATE_DIR, XDG_CONFIG_HOME | Env::state_dir | where state.json lives |
SHELLGAME_WORKSPACE | Env::workspace_override | workspace of a new game |
SHELLGAME_WRAPPER | Env::wrapped | the binary runs inside the game shell |
TMPDIR | Env::tmpdir | a second place remove may delete from |
SHELL | Env::shell | the player’s login shell, for shell detection |
SHELLGAME_FORCE_SHELL | Env::force_shell | bash or fish: which game shell to start |
SHELLGAME_UPDATE_URL | Env::update_url | where shellgame update downloads from |
An empty value counts as unset for every variable, as it does in the Python version, where ""
is falsy. NO_COLOR and friends are not read here: anstream handles them when output is
written.
Structs§
- Env
- What the game knows about the process it runs in. Built once by
Env::from_processand passed down by reference; tests build one withEnv::newor a struct literal.