Usage

The ucode interpreter executes programs from source files, expressions or standard input. The first file argument is the program, every further argument is passed to it as data; ucode -h prints the full help text.

Options

OptionEffect
-hdisplay help and exit
-e exprexecute the expression expr
-p exprexecute expr and print the result afterwards
-Rprocess the input as plain script code (the default)
-T[flag,...]process the input as a template; no-lstrip keeps leading whitespace before block tags, no-rtrim keeps the trailing newline after them
-D [name=]valuedefine a global variable; without name, value must be a JSON dictionary whose properties become globals
-F [name=]pathlike -D, but the value is read from the JSON file in path
-U nameremove the global variable name
-l [name=]libpreload the module lib, optionally aliased to name
-L patternprepend pattern to the module search path; a pattern without * is added twice, once with /*.so and once with /*.uc appended
-c[flag,...]compile to bytecode instead of executing; flags: no-interp, interp=..., dynlink=..., module
-o pathoutput file for -c (default ./uc.out)
-somit debug information from compiled bytecode
-ttrace the VM execution to standard error
-g intervalrun the cycle collector every interval object allocations
-Senable strict mode
-x[expr]start the interactive debugger, optionally breaking at expr
-X[expr]enable the debugger for later remote attach, optionally with a breakpoint at expr

Examples

$ ucode -p "2 ** 10"
1024

$ ucode program.uc

$ ucode -c -o program.out program.uc

$ ucode -T -D name=lan -D up=true iface.tpl

Preloading a module makes it available under its name (or the given alias):

$ ucode -lfs -e 'printf("%J\n", fs.access("/etc"))'
true

Script arguments

Extra command line parameters are passed to the script in the ARGV global (an array of strings); SCRIPT_NAME holds the path the script was invoked with:

$ ucode foo.uc foo bar
$ ./foo.uc foo bar          # when the script carries a shebang line
print(ARGV, "\n");          // [ "foo", "bar" ]
print(SCRIPT_NAME, "\n");   // ./foo.uc