Skip to main content

Module shell

Module shell 

Source
Expand description

Shell export: the few variables a shell working in this repository benefits from, emitted so that eval "$(majordomus env export)" is safe whatever the repository is called and wherever it lives.

§Why this exists at all

Without it, a .envrc grows a pipeline: a git here, a sed there, a jq to read the server’s lease. Each is a second implementation of something this executable already knows, none of them is tested, and all of them run on every cd. The adapter should carry no logic, so the logic lives here and the adapter evaluates it.

§Escaping

Every value is quoted, not escaped-in-place: a repository whose path holds a quote, a space, a newline, a $(...) or a backtick must produce an assignment that a shell reads as one literal string. POSIX single quotes admit no interpolation at all, so the only character needing care is the quote itself. fish uses single quotes too but does process backslash inside them, so it gets its own rule rather than the same one with a hope attached.

quote_posix and quote_fish are exercised against a corpus of hostile values in nothing_in_a_value_can_escape_its_quotes, and the emitted script is run through a real shell in the crate’s integration tests.

Structs§

Variable
One variable an export may set.

Enums§

Dialect
The shell dialect an export is written for.

Functions§

export
The script that sets them.
is_identifier
Is this a name a shell will accept as a variable?
quote_fish
Quote a value for fish.
quote_posix
Quote a value for sh, bash, zsh and direnv.
variables
The variables this snapshot exports, in a stable order.