Next: Acknowledgments Up: Reference Manual of the Previous: 8.10 Calling Lua Functions

9 Lua Stand-alone

Although Lua has been designed as an extension language, the language can also be used as a stand-alone interpreter. An implementation of such an interpreter, called simply lua, is provided with the standard distribution. This program can be called with any sequence of the following arguments:

-v
prints version information.
-
runs interactively, accepting commands from standard input until an EOF.
-e stat
executes stat as a Lua chunk.
var=exp
executes var=exp as a Lua chunk.
filename
executes file filename as a Lua chunk.

All arguments are handle in order. For instance, an invocation like
$ lua - a=1 prog.lua
will first interact with the user until an EOF, then will set a to 1, and finally will run file prog.lua.

Please notice that the interaction with the shell may lead to unintended results. For instance, a call like

$ lua a="name" prog.lua
will not set a to the string "name". Instead, the quotes will be handled by the shell, lua will get only a=name to run, and a will finish with nil. Instead, one should write
$ lua 'a="name"' prog.lua


Next: Acknowledgments Up: Reference Manual of the Previous: 8.10 Calling Lua Functions