std.os Module Reference

The std.os module enables inspecting environment variables, host operating system properties, and controlling process termination.

os_example.sp
1import std.io;
2import std.os;
3
4fn main() -> void {
5 let platform = os.platform();
6 let user = os.env("USER") ?? os.env("USERNAME") ?? "Unknown";
7
8 println("Platform: ${platform}");
9 println("Active User: ${user}");
10}

Exported Functions

os.platform

Native Builtin
fn os.platform() -> string

Returns the host operating system string ('windows', 'linux', or 'macos').

Returns:string

os.env

Native Builtin
fn os.env(string name) -> string?

Retrieves the value of an environment variable, returning null if unset.

Parameters
name(string)
Environment variable key.
Returns:string?

os.exit

Native Builtin
fn os.exit(int code) -> void

Terminates the host process immediately with the specified exit status.

Parameters
code(int)
Process return code.
Returns:void