Relux provides built-in functions (BIFs) that are always available without imports. BIFs are divided into two categories based on their purity — whether they require a shell context to operate.
Generate a random UUID v4 (e.g. "550e8400-e29b-41d4-a716-446655440000").
rand
rand(n)
string
Generate a random alphanumeric string of length n. Errors if n is not a valid integer.
rand
rand(n, mode)
string
Generate a random string of length n using the given charset mode. Modes: alpha, num, alphanum, hex, oct, bin. Errors if mode is unknown or n is not a valid integer.
Bind to an ephemeral TCP port on 127.0.0.1 and return the port number. The port is released after the call, so it may be reused — call this close to where the port is needed.
which
which(name)
string
Search PATH for an executable named name. Returns the absolute path to the first match, or "" if not found. Checks that the file has an executable permission bit set. If name contains a path separator, checks that path directly instead of searching PATH.
sleep
sleep(duration)
""
Pause execution for duration. Accepts humantime format: 500ms, 2s, 1m30s, etc. Errors if the duration is invalid.
Match the shell prompt configured in Relux.toml. Advances the output cursor past the prompt.
match_ok
match_ok()
string
Match the shell prompt, send echo $?, match 0, and match the prompt again. Verifies the previous command exited with status 0.
match_not_ok
match_not_ok()
string
Match the shell prompt, verify the previous command exited with a non-zero status, and match the prompt again. The inverse of match_ok().
match_not_ok
match_not_ok(code)
string
Match the shell prompt, verify the previous command exited with a specific non-zero status code, and match the prompt again. Like match_exit_code(code) but also asserts the code is non-zero.
match_exit_code
match_exit_code(code)
string
Send echo $?, match code, and match the prompt. Verifies the previous command exited with the given status. code is passed as a bare literal (e.g. match_exit_code(1)).