Reference · Files and processes

exit

signature
exit(int=) -> null

What it does

Ends a script at once with the status n, from 0 to 255, or 0 if it is left out, once what it printed is out: the status a shell's $?, a make rule or CI reads. A script that ends by itself ends with 0, and one that fails with 1.

Examples

in a program
// quillo run check.qwe -- data.jsonlet r = json.parse(read_file(args()[0]))if is_err(r) {    print(`not JSON: ${r.error}`)    exit(2)}print("ok")

Edge cases

Errors

A status outside 0 to 255, or not an int, is a runtime error; and so is exit in a program that serves, as a request is not the one to stop the server.

this one fails
exit(256)
output
line 1: `exit` takes a status from 0 to 255, got 256

Chaining

None.

See also

stdin, read_line, args

Thread
3Useful? Like it, or add to its thread below.

Thread 0 posts

On exit(): questions, tips, corrections, and code that uses it.

No posts yet. The first one opens the thread.

    Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo