MAN page from Fedora 12 lua-5.1.4-4.fc12.x86_64.rpm
Section: User Commands (1)
Updated: $Date: 2006/01/06 16:03:34 $Index
lua - Lua interpreter
is the stand-alone Lua interpreter.It loads and executes Lua programs,either in textual source form orin precompiled binary form.(Precompiled binaries are output byluac
,the Lua compiler.)lua
can be used as a batch interpreter and also interactively.
The givenoptions(see below)are executed and thenthe Lua program in filescriptis loaded and executed.The givenargsare available toscriptas strings in a global table namedarg.If these arguments contain spaces or other characters special to the shell,then they should be quoted(but note that the quotes will be removed by the shell).The arguments inargstart at 0,which contains the string'script'.The index of the last argument is stored inarg.n.The arguments given in the command line beforescript,including the name of the interpreter,are available in negative indices inarg.
At the very start,before even handling the command line,luaexecutes the contents of the environment variableLUA_INIT,if it is defined.If the value ofLUA_INITis of the form'@filename',thenfilenameis executed.Otherwise, the string is assumed to be a Lua statement and is executed.
Options start with'-'and are described below.You can use'--'to signal the end of options.
If no arguments are given,then-v -iis assumed when the standard input is a terminal;otherwise,-is assumed.
In interactive mode,luaprompts the user,reads lines from the standard input,and executes them as they are read.If a line does not contain a complete statement,then a secondary prompt is displayed andlines are read until a complete statement is formed ora syntax error is found.So, one way to interrupt the reading of an incomplete statement isto force a syntax error:adding a';' in the middle of a statement is a sure way of forcing a syntax error(except inside multiline strings and comments; these must be closed explicitly).If a line starts with'=',thenluadisplays the values of all the expressions in the remainder of theline. The expressions must be separated by commas.The primary prompt is the value of the global variable_PROMPT,if this value is a string;otherwise, the default prompt is used.Similarly, the secondary prompt is the value of the global variable_PROMPT2.So,to change the prompts,set the corresponding variable to a string of your choice.You can do that after calling the interpreteror on the command line(but in this case you have to be careful with quotesif the prompt string contains a space; otherwise you may confuse the shell.)The default prompts are "> " and ">> ".
- load and execute the standard input as a file,that is,not interactively,even when the standard input is a terminal.
- -e stat
- execute statementstat.You need to quotestat if it contains spaces, quotes,or other characters special to the shell.
- enter interactive mode afterscriptis executed.
- -l name
- callrequire('name')before executingscript.Typically used to load libraries.
- show version information.
Error messages should be self explanatory.
R. Ierusalimschy,L. H. de Figueiredo,andW. Celes
- SEE ALSO
This document was created byman2html,using the manual pages.