env.nx
buildroot/runtime/env.nx
about
env.nx -- parse .env / dotenv-style configuration files.
The de facto standard for deployment config (Heroku, Vercel,
Docker Compose, direnv, 12-factor apps all use this format).
Line-oriented; each non-comment non-blank line is:
KEY=value
KEY=\"value with spaces\"
KEY='single-quoted'
KEY= (explicit empty)
Comments start with '#'. Blank lines ignored. Unquoted values
are trimmed of leading/trailing whitespace; quoted values are
taken verbatim between quote marks (no escape handling for
simplicity -- callers with \"dangerous\" values use JSON in the
.env + parse with json.nx).
Keys must match [A-Za-z_][A-Za-z0-9_]* or the line is skipped.
Used by: every Nishi service runtime for config, local dev
workflows, CI environment injection.
Complements ini.nx (which has sections) + query.nx (URL encode)
by covering the linear-only case.
Invariants:
E1 Zero-alloc: offsets into caller's buffer.
E2 Malformed lines silently skipped (caller logs if needed).
E3 Duplicate keys both emitted; caller-supplied last-wins
semantics if desired.
E4 CRLF and bare LF line endings both accepted.
dependencies 1 imports · 0 importers
imports: syscalls.nx
imported by: nobody (leaf or entry point)
structs
| 37 | struct EnvEntry { |
consts
| 35 | const ENV_ERR_OVERFLOW: i64 = -1 |
functions
| 42 | func env_is_key_start(b: i64) -> i64 { |
| 53 | func env_is_key_cont(b: i64) -> i64 { |
| 61 | func env_is_ws(b: i64) -> i64 {
called by 1: env_parse |
| 68 | func env_eol(buf: *u8, n: i64, off: i64) -> i64 {
called by 1: env_parse |
| 78 | func env_parse(buf: *u8, n: i64, |
| 200 | func env_find(buf: *u8, entries: *EnvEntry, count: i64, |
| 223 | func main() -> i64 { |