Skip to main content

Module envfile

Module envfile 

Source
Expand description

.env files (--env <FILE>, repeatable): a dependency-free dotenv subset.

Lines are KEY=VALUE with optional export prefix; # starts a comment (a whole line, or trailing an unquoted value); single quotes are literal; double quotes understand \n \t \r \\ \". There is no $VAR interpolation inside the file — the config layer’s ${VAR:-default} expansion already exists for that, and two interpolation passes with different rules is how values get mangled silently.

Precedence is the dotenv convention: the real environment wins over any file (a deployment override beats the checked-in defaults file), and among files the later wins for keys the environment does not pin. A malformed line or an unreadable file is a startup refusal naming file and line — fail-closed, like every other config error.

Functions§

load_files
Load every --env file in order and fold them into one map — later files win. The caller applies the real-environment-wins rule (it knows the environment; this function deliberately does not read it, so tests can).
parse
Parse one file’s content. Returns pairs in file order.