Environment
Process arguments and borrowed environment lookup through std.env.
std.env contains the small process-environment helpers used by command-line
programs. The current surface is deliberately narrow: borrowed argument access
and borrowed environment lookup.
Current-directory access, environment mutation, environment iteration,
subprocess management, and high-level exit helpers are not part of this module.
Use std.os for low-level process exits.
import std.env;
import std.io;
fn main() {
let args = env.args();
io.println("argc={args.length}");
if args.length > 1 {
io.println("first={args[1]}");
}
}
args() -> const [str] returns the process argument slice for the current
program. args[0] is the executable path or name supplied by the host runtime,
and later elements are user arguments.
The returned slice is borrowed process-startup storage. Programs must not store it in longer-lived owners or mutate it. It remains valid for the duration of the process.
import std.env;
import std.io;
fn main() {
let home = env.get("HOME");
if home == null {
io.eprintln("HOME is not set");
return;
}
io.println("HOME={home}");
}
get(name: str) -> str? returns the process environment value for name, or
null when the variable is absent. The returned string is borrowed host
environment storage. Zynx does not expose environment mutation here, so the
borrow is stable for normal Zynx code until process exit.
Environment text is treated as process text and should be valid UTF-8 for portable Zynx programs. Byte-oriented environment handling is outside this checked text API.
| Symbol | Signature | Notes |
|---|---|---|
args | args() -> const [str] | Returns borrowed process arguments. |
get | get(name: str) -> str? | Returns a borrowed environment value, or null when missing. |