os
OS thin wrapper - execute a shell command string, read/set environment variables, get and change the current working directory, get the process ID, get command-line arguments, exit the process, and read/write files with type-checked paths. A validated thin layer over host syscalls.
Load with: use os
What this module does
os is a convenience façade over raw __sys_* syscalls
and host_run_ctx bindings. Every function validates its argument
types and throws a clear eru.bang error on misuse. It mirrors
the interface of host but adds stricter type guards and covers
the most common OS operations in one import.
Quick example
use os
# Run a shell command
osrun("ls -la")
# Environment
prn(osenv("HOME"))
ossetenv("DEBUG", "1")
# Process
prn(oscwd())
osset("/tmp")
prn(ospid())
prn(osarg()) # ["./myapp", "--flag"]
# File I/O
src = osrd("input.txt")
oswr("output.txt", src)
# Print and exit
osprntl("done")
osext(0)
# Namespace style
prn(os.env("PATH"))
Functions
Process
osrun(cmd) / os.run(cmd)Executes shell command string cmd via __os_run.
osarg()Returns the command-line argument list. Checks host context first, then __sys_args.
ospid()Returns the current process ID.
osext(code)Exits the process with numeric exit code.
Environment
osenv(key) / os.env(key)Gets environment variable key. Checks host context first.
ossetenv(key, val) / os.setenv(key, val)Sets environment variable key to val.
Filesystem
oscwd()Returns the current working directory.
osset(path)Changes the current working directory to path.
osrd(path)Reads a file as text. Errors if path is not a string.
oswr(path, content)Writes text to a file. Both arguments must be strings.
Output
ostpri(text) / os.tepri(text)Writes text to stdout without a trailing newline.
osprntl(text) / os.prntl(text)Writes text to stdout with a trailing newline.
Notes
- Requires
eruandhost_run_ctx.