Quirrel4.41.0

__argv

Global, available without an import

The command line the host was started with, as an array of strings.

Notes

This is the host's raw argv, not a cleaned list of script arguments. It starts with the interpreter path, then the script path, and it also carries the interpreter's own options, so the same script sees a different array depending on how it was launched. Take the arguments you want by position from the end, or match them by name; do not assume __argv has a fixed length.

Root table names are not visible to module code on their own, so reach it through getroottable rather than by writing __argv directly. A bare __argv fails to compile with Unknown variable [__argv].

The host installs it, not the VM. An application that embeds Quirrel and never calls sqstd_register_command_line_args has no __argv, so treat a missing slot as normal.

Example

examples/globals/__argv.nut
let root = getroottable()

// module code cannot see root table names on its own
println("__argv in root =", "__argv" in root)
println("type(root.__argv) =", type(root.__argv))

// the interpreter's own options are in there too, so the length is not fixed:
// printing it would only record how this one run was launched
println("root.__argv.len() >= 2 =", root.__argv.len() >= 2)
Output:
__argv in root = true
type(root.__argv) = array
root.__argv.len() >= 2 = true

See also

getroottableReturns the root table.
getenvReturns the value of the environment variable or null
globalsmodule index