sys module
Process-level information: command-line arguments, environment variables, current directory, and a way to exit with a status code.
import "sys" as sys;
print("argv count:", sys.argc());
print("user:", sys.env("USER"));
print("cwd:", sys.cwd());
API
| Function | Description |
|---|---|
sys.argc() → number | Count of arguments passed to the script (not counting bnl itself or the script path). |
sys.arg(i) → string | The i-th argument (0-indexed). Throws on out-of-range. |
sys.env(name) → string | null | Look up one environment variable. |
sys.envs() → map | Snapshot of every environment variable as a {KEY: value} map. |
sys.cwd() → string | The process's current working directory. |
sys.exit(code) | Exit the process with the given status code. |
sys.platform | "windows", "linux", or "macos". |