sys
the world outside zil: script arguments, environment variables, other programs, opening files, the clipboard, and the web
Permissions: env, processes, open, network, clipboard, exit
Reaches outside zil: the arguments a script was given, environment variables, other programs, files and links to open, the clipboard and web requests. What a host allows is controlled by its permissions.
Tags: files, network
argsthe command-line arguments given after the script’s name (or after -e code), as a list of strings: for zil script.zil a b, that’s [“a”, “b”]envthe value of an environment variable, or nil if it isn’t setexitstop the script now, with an exit code for whatever ran itshrun a command line through the system shell (sh, or cmd on Windows) and return what it printed, without the final newlineexecrun a program directly, without a shell, given as a list of its name and argumentsrunrun a command line through the system shell and return {code, out, err}: its exit code, output and error outputopenopen a file or folder with the system’s default program, and return its pathcopycopy a value to the clipboard, as print would show it, and return itpastethe text on the clipboardfetchdownload a URL and return its content as a string
Functions
Section titled “Functions”args() -> list
the command-line arguments given after the script’s name (or after -e code), as a list of strings: for zil script.zil a b, that’s [“a”, “b”]
1args()[]See also env
env() -> map / env(name: str) -> str|nil
the value of an environment variable, or nil if it isn’t set
With no name, all of them as a map
1env("ZIL_SURELY_UNSET")nilSee also args
exit(code: int = 0) -> nil
stop the script now, with an exit code for whatever ran it
0 means success, anything else failure
1exit(1)See also args
sh(cmd: str) -> str
run a command line through the system shell (sh, or cmd on Windows) and return what it printed, without the final newline
An error if the command fails
1sh("git rev-parse --short HEAD")2sh("ls").lines.lenSee also run
exec(argv: list, *more: list, stdin?: any, stderr?: str, tty: bool = false) -> str|bytes|int
run a program directly, without a shell, given as a list of its name and arguments
With several lists, each one’s output is piped into the next. Returns what the last printed, without the final newline (as bytes if it isn’t text), and is an error if one fails. !prog args turns into a call to exec
stdina value to feed the first program as inputstderra file to send error output tottyshow the output in the terminal and return the exit code instead
1exec(["git", "log", "--oneline"], ["head", "-3"])2!objdump -d a.out | grep callrun(cmd: str) -> map
run a command line through the system shell and return {code, out, err}: its exit code, output and error output
Never an error just because the command failed
1run("git status").codeSee also sh
open(path: str) -> str
open a file or folder with the system’s default program, and return its path
1open("report.pdf")See also exec
copy(v: any) -> any
copy a value to the clipboard, as print would show it, and return it
1sh("git rev-parse HEAD") |> copySee also paste
paste() -> str
the text on the clipboard
1paste().lines.lenSee also copy
fetch(url: str) -> str
download a URL and return its content as a string
An error if the server answers with an error status
1fetch("https://api.github.com/repos/rust-lang/rust").from_json.stargazers_countSee also from_json
More examples
Section titled “More examples”1# arguments after the script2args()[]3# is a variable set?4env("ZIL_SURELY_UNSET") == niltrue5# are any environment variables set?6env().len > 0trueExample results generated on 2026-11-04. Ones using now, today or randomness will differ when you run them.