Module: sys.env

Source: ./sys/env.reef


Overview

sys/env - Environment variable operations

Provides functions for working with environment variables. Uses POSIX functions via C FFI.


Functions

fn get_env(name: string): option.Option[string]

Gets the value of an environment variable Returns Some(value) if set, None if the variable is unset. Distinguishes "unset" from "set but empty" via reef_getenv_exists (the underlying NULL check), not the string length — a set-but-empty var (e.g. VAR=) is Some(""), not None. This agrees with has_env, which is also NULL-based.

BUG-147: runtime.reef_getenv now boundary-copies into a headered heap string itself (reef_getenv's NULL case already falls back to an empty heap string), so the old local str.length + reef_string_alloc + libc.strcpy re-copy here was redundant — return the runtime's copy directly.

fn has_env(name: string): bool

Checks if an environment variable is set

fn set_env(name: string, value: string): bool

Sets an environment variable Returns true on success

fn unset_env(name: string): bool

Removes an environment variable Returns true on success

fn get_env_or(name: string, default_value: string): string

Gets an environment variable with a default value Returns default_value if the variable is not set


Generated by reefc doc