← all modules
module

stdlib::env

defined in C:\Users\bye45\.glide\bin/src/stdlib/env.glide

Number of CLI arguments. Index `0` is the program path; user args

fn fn env_args_count() -> int

Number of CLI arguments. Index 0 is the program path; user args start at 1, mirroring C's argc.

glide
for let i: int = 0; i < env_args_count(); i++ {
    println!(i, env_args_at(i));
}
fn fn env_args_at(i: int) -> string

CLI argument at index i. Returns "" for out-of-range indices.

glide
let prog: string = env_args_at(0);   // program path
let first: string = env_args_at(1);  // first user arg, "" if missing
fn fn env_args() -> *Vector<string>

All user-supplied CLI args as a Vector<string>, skipping the program path at index 0.

glide
let args: *Vector<string> = env_args();
for let i: int = 0; i < args.len(); i++ { println!(args.get(i)); }
fn fn env_get(name: string) -> string

Look up environment variable name. Returns "" when unset. Use env_has if you need to distinguish "unset" from "empty value".

glide
let path: string = env_get("PATH");
let dirs: *Vector<string> = path.split(os_path_list_sep());
fn fn env_has(name: string) -> bool

true if the variable is set with a non-empty value.

glide
if env_has("DEBUG") { println!("verbose mode on"); }
fn fn env_exit(code: int)

Terminate the process with code. Skips Glide-side cleanup — defer blocks and auto-drops in higher stack frames will NOT run.

glide
if !cfg.ok { eprintln(cfg.err); env_exit(1); }
fn fn env_set(name: string, value: string) -> !void

Set environment variable name to value. Overwrites any existing value. Returns Err if the OS rejects the call (very rare — typically a name with = in it, or a system-level limit).

glide
let r: ! = env_set("LANG", "en_US.UTF-8");
if !r.ok { eprintln(r.err); }
env_get("LANG");   // "en_US.UTF-8"
fn fn env_unset(name: string) -> !void

Remove environment variable name. Idempotent — calling on an unset var is not an error.

glide
env_unset("DEBUG");
env_has("DEBUG");   // false
struct struct EnvKV

One entry of the process environment, decomposed into key and value. Returned by env_all().

fn fn env_all() -> *Vector<EnvKV>

Snapshot of the entire process environment. The list is taken at call time and is a copy — mutating env via env_set / env_unset after this call does NOT update the returned vector.

glide
let all: *Vector<EnvKV> = env_all();
for let i: int = 0; i < all.len(); i++ {
    let kv: EnvKV = all.get(i);
    println!(kv.key, "=", kv.value);
}
fn fn env_expand(s: string) -> string

Expand $VAR, ${VAR} and %VAR% references in s to their current env values. Unknown vars expand to empty string. Literal $ followed by a non-name character (or %X without closing %) is preserved.

glide
env_expand("home is $HOME");          // POSIX style
env_expand("home is ${HOME}/cache");  // POSIX braces
env_expand("data: %APPDATA%\\app");   // Windows style