Syntax
The language at a glance. help("syntax") shows the same in the REPL.
values
Section titled “values”1# decimals are exact20.1 + 0.20.33# dividing integers gives an exact fraction47 / 23.55# // divides and rounds down67 // 237# ** is power, and ^ is xor, not power82 ** 1010249# hex and binary numbers stay in their base100xff + 10x10011# units attach to numbers1260 km/h to m/s16.6667 m/s13# a number touching a name multiplies, with no space: variables win over units, and a space always means the unit14x = 3; [2x, 2pi, 2(x + 1), 3 m][6, 6.28319, 8, 3 m]15# a function and a space before a value calls it16sqrt 16 + sin 90 deg517# percentages1880 + 15%9219# clock arithmetic: values that wrap around2010 mod 12 + 53 (mod 12)21# {...} in a string puts in a value22"2 + 2 = {2 + 2}""2 + 2 = 4"23# slices, where negative positions count from the end24"hello"[-3..]"llo"25# r"..." is a regular expression26"a1b22".find_all(r"\d+")["1", "22"]27# b"..." is raw bytes28b"\x7fELF"[1..].str"ELF"29# a..=b counts from a to b, a..b stops just before b301..=5[1, 2, 3, 4, 5]31# maps hold values under names32{a: 1, b: 2}.b21# x.f(y) means f(x, y)2"a-b".split("-")["a", "b"]3# calls with no arguments need no parentheses4"hi".upper"HI"5# |> passes a value to a function6[3, 1, 2] |> sort[1, 2, 3]7# _ marks where the piped value goes83.14159 |> round(_, 2)3.149# |x| ... is a small function, a lambda10[1, 2, 3].map(|x| x * 10)[10, 20, 30]11# _ in parentheses or an argument is a lambda parameter12[1, 2, 3].map(_ * 10)[10, 20, 30]13# to converts a value to a unit, base, type or zone14255 to hex0xffstatements
Section titled “statements”1# assignment, with no declaring needed2x = 5; x += 2; x73# if gives a value, so it can be used anywhere4if 3 > 2 { "yes" } else { "no" }"yes"5# for loops over a range, list or other collection6t = 0; for i in 1..=4 { t += i }; t107# unpack a list into names, _ skips an item8[a, [b, _]] = [1, [2, 3]]; a + b39# while10n = 3; while n > 0 { n -= 1 }; n011# fn defines a function12f = fn(x) { return x * 2 }; f(4)813# f(x: type) = ... names a function, and the same name with other types adds an overload14size(x: int) = x; size(s: str) = s.len; [size(5), size("abc")][5, 3]15# comparisons chain, as in math16x = 5; 0 < x <= 10true17# # starts a comment that runs to the end of the line, and a new line or a semicolon ends a statementCommand mode
Section titled “Command mode”Command mode is for the file and program work you would otherwise switch to a terminal for.
One part is the built-in shortcuts: zil functions for things commonly done in a shell.
# list a folder, hidden files tools -la src# → ls("src", long: true, all: true)# lines with err, ignoring casegrep -i err app.log# → grep(read_file("app.log"), "err", ignore_case: true)# delete a folder and what's in itrm -rf build# → rm("build", recursive: true, force: true)# a file's contentscat a.txt# → cat("a.txt")Also, regular shell commands can be run with ! in front of them. The output is shown as it happens, and the result is the program’s exit code: 0 for success.
# output shows as it happens!git status# → exec(["git", "status"], tty: true)# interactive programs work too!python# → exec(["python"], tty: true)# assigned, the output is captured insteadlog = !git log --oneline -5# → log = exec(["git", "log", "--oneline", "-5"])# two programs, joined by a system pipe!git log --oneline | head -3# → exec(["git", "log", "--oneline"], ["head", "-3"], tty: true)A few operators change meaning too.
# | passes a result on, instead of bitwise orls src | grep rs# → ls("src") |> grep("rs")# > writes a file, instead of greater thanls > files.txt# → write_file(ls(), "files.txt")# < feeds a file to a program!sort < names.txt# → exec(["sort"], stdin: read_bytes("names.txt"), tty: true)# |> means the same as in zil, and goes back to itls src |> len# → ls("src") |> lenhelp("shell") has the same in the REPL.
Commands
Section titled “Commands”search functions whose name or description mentions a word, as text
search str# → search("str")read the contents of one or more files, as text joined into one string, or as bytes with the bytes flag
-b,--bytesgive the contents as bytes, for files that aren’t text
read -b a.out# → read("a.out", bytes: true)read_file the contents of one or more files, joined into one string
cat a.txt b.txt# → cat("a.txt", "b.txt")ls what’s in a directory, as a table of name, type, size and modified
-a,--allinclude names starting with a dot, which are hidden otherwise-l,--longaccepted out of habit: the table always has the details
ls -la src# → ls("src", long: true, all: true)du the biggest files and folders directly in dir, largest first, with each folder counted for everything inside it
du src 5# → du("src", "5")rm delete files and empty directories
-r,--recursivealso directories and everything in them-f,--forceskip paths that don’t exist instead of failing-n,--dry-runlist what would change, as a table of op, from and to, and change nothing
rm -rf build# → rm("build", recursive: true, force: true)mv move or rename files and directories
-n,--dry-runlist what would change, as a table of op, from and to, and change nothing
mv *.log logs# → mv(*glob("*.log").name, "logs")cp copy files
-r,--recursivecopy directories too-n,--dry-runlist what would change, as a table of op, from and to, and change nothing
cp -r src backup# → cp("src", "backup", recursive: true)mkdir create directories, along with any missing folders above them
-p,--parentsaccepted out of habit: missing folders above are always made-n,--dry-runlist what would change, as a table of op, from and to, and change nothing
mkdir -p out/logs# → mkdir("out/logs", parents: true)cwd the current directory, which relative paths start from
cwd# → cwd()pwd the current directory, the same as cwd() under the shell’s name
pwd# → pwd()cd change the current directory and return the new one
cd ../notes# → cd("../notes")grep the lines of a string, or items of a list, that contain pat
-i,--ignore-caseignore case-v,--invertkeep the lines that don’t match instead-c,--countcount the matches instead
grep -i err app.log# → grep(read_file("app.log"), "err", ignore_case: true)wc count lines, words and bytes, like the Unix wc tool
-l,--linesjust the line count-w,--wordsjust the word count-c,--bytesjust the byte count
wc -l notes.txt# → wc(read_file("notes.txt"), lines: true)diff what changed from text a to b, line by line, or nil if nothing did
-p,--plainno colors, even on a terminal-b,--bytesthe command reads the files as bytes, for the bytes diff-t,--tablea table of changed lines instead of hunks-B,--basefor the bytes diff, the address the first byte is at
diff notes.txt notes2.txt# → diff(read_file("notes.txt"), read_file("notes2.txt"))hexdump bytes shown as a hex dump, like the xxd tool, or just n bytes around address at
-p,--plainno colors, even on a terminal-t,--textonly the text column, as one line-B,--basethe address the first byte is shown at, true for 0x400000
xxd a.out 0x1000# → xxd(read_bytes("a.out"), "0x1000")diff what changed from bytes a to b, by hex dump row, or nil if nothing did
-p,--plainno colors, even on a terminal-t,--tablea table of differing bytes instead of hunks-B,--basethe address the first byte is at, true for 0x400000
diff -b a.out b.out# → diff(read_bytes("a.out"), read_bytes("b.out"))strings the readable text hidden in binary data: every run of at least min printable characters, like the Unix tool
-t,--tablea table of offset and text instead of a list-B,--basethe address the first byte is at, true for 0x400000
strings -t a.out# → strings(read_bytes("a.out"), table: true)# a command on its own runs with no argumentsls# → ls()# * matches any part of a namerm *.tmp# → rm(*glob("*.tmp").name)# put names with spaces in double quotescat "my file.txt"# → cat("my file.txt")# flags are letters that combine, -la is -l and -a, or names: --all is -a# grep, wc, xxd and strings read the files you name, instead of taking textmixing in zil
Section titled “mixing in zil”# {expr} passes a zil value as one argumentrm {old}# → rm(old)# |> hands the result to a zil functionls src |> len# → ls("src") |> len# with parentheses it's an ordinary call, not a command: files = ls("src")# a variable with a command's name wins: after cat = 5, cat foo is no longer the cat commandrunning programs
Section titled “running programs”# ! runs any program, showing its output!git status# → exec(["git", "status"], tty: true)# on a line by itself, the result is the program's exit code: 0 for success# assigned or piped, its output is capturedlog = !git log --oneline -5# → log = exec(["git", "log", "--oneline", "-5"])# when output is captured, a program that fails is an error# ! right before ( is still "not": !(x) means not x# | feeds one command's result into the nextls src | grep rs# → ls("src") |> grep("rs")# after |, any other name is a programls | sort# → exec(["sort"], stdin: ls(), tty: true)# between two programs, | is an ordinary system pipe!git log --oneline | head -3# → exec(["git", "log", "--oneline"], ["head", "-3"], tty: true)redirection
Section titled “redirection”# > writes a file, >> adds to the end of onels > files.txt# → write_file(ls(), "files.txt")# < feeds a file to a program as its input!sort < names.txt# → exec(["sort"], stdin: read_bytes("names.txt"), tty: true)# 2> sends a program's errors to a file!make 2> errors.txt# → exec(["make"], stderr: "errors.txt", tty: true)REPL only
Section titled “REPL only”# help topic shows a help page, the same as help("topic")# ? after a name shows its help: upper? is help upper, and now.moon_phase? is help moon_phasecoming from bash
Section titled “coming from bash”# 'single quotes' aren't strings: write "...", or r"..." to keep backslashes as they are# {a,b} brace expansion isn't supported: pass a list, {["a", "b"]}# $VAR isn't a variable, since $ is for money like $5: write {env("VAR")}# ls - l doesn't work: a flag's letters must touch its dash, -l# ls | where(...) is an error, since after | a name means a program: use |> to hand the result to zil# 2>&1 isn't supported: send error output to a file with 2> fExample results generated on 2026-11-04. Ones using now, today or randomness will differ when you run them.