1LUA(1)                      General Commands Manual                     LUA(1)
2
3
4

NAME

6       lua - Lua interpreter
7

SYNOPSIS

9       lua [ options ] [ script [ args ] ]
10

DESCRIPTION

12       lua is the stand-alone Lua interpreter.  It loads and executes Lua pro‐
13       grams, either in textual source form or  in  precompiled  binary  form.
14       (Precompiled  binaries  are output by luac, the Lua compiler.)  lua can
15       be used as a batch interpreter and also interactively.
16
17       The given options (see below) are executed and then the Lua program  in
18       file  script  is  loaded and executed.  The given args are available to
19       script as strings in a global table named arg.  If these arguments con‐
20       tain  spaces or other characters special to the shell, then they should
21       be quoted (but note that the quotes will be removed by the shell).  The
22       arguments  in  arg start at 0, which contains the string 'script'.  The
23       index of the last argument is stored in arg.n.  The arguments given  in
24       the  command line before script, including the name of the interpreter,
25       are available in negative indices in arg.
26
27       At the very start, before even handling the command line, lua  executes
28       the  contents  of  the environment variable LUA_INIT, if it is defined.
29       If the value of LUA_INIT is of the form '@filename', then  filename  is
30       executed.   Otherwise,  the string is assumed to be a Lua statement and
31       is executed.
32
33       Options start with '-' and are described below.  You can  use  '--'  to
34       signal the end of options.
35
36       If  no  arguments  are  given,  then -v -i is assumed when the standard
37       input is a terminal; otherwise, - is assumed.
38
39       In interactive mode, lua prompts the user, reads lines from  the  stan‐
40       dard  input,  and  executes  them as they are read.  If a line does not
41       contain a complete statement, then a secondary prompt is displayed  and
42       lines  are  read until a complete statement is formed or a syntax error
43       is found.  So, one way to interrupt the reading of an incomplete state‐
44       ment is to force a syntax error: adding a ';' in the middle of a state‐
45       ment is a sure way of forcing a syntax error (except  inside  multiline
46       strings  and  comments;  these  must  be closed explicitly).  If a line
47       starts with '=', then lua displays the values of all the expressions in
48       the remainder of the line. The expressions must be separated by commas.
49       The primary prompt is the value of the global variable _PROMPT, if this
50       value  is  a string; otherwise, the default prompt is used.  Similarly,
51       the secondary prompt is the value of the global variable _PROMPT2.  So,
52       to  change  the  prompts, set the corresponding variable to a string of
53       your choice.  You can do that after calling the interpreter or  on  the
54       command  line  (but  in this case you have to be careful with quotes if
55       the prompt string contains a  space;  otherwise  you  may  confuse  the
56       shell.)  The default prompts are "> " and ">> ".
57

OPTIONS

59       -      load  and  execute  the  standard  input as a file, that is, not
60              interactively, even when the standard input is a terminal.
61
62       -e stat
63              execute statement stat.  You need to quote stat if  it  contains
64              spaces, quotes, or other characters special to the shell.
65
66       -i     enter interactive mode after script is executed.
67
68       -l name
69              call require('name') before executing script.  Typically used to
70              load libraries.
71
72       -v     show version information.
73

SEE ALSO

75       luac(1)
76       http://www.lua.org/
77

DIAGNOSTICS

79       Error messages should be self explanatory.
80

AUTHORS

82       R. Ierusalimschy, L. H. de Figueiredo, and W. Celes
83
84
85
86                         $Date: 2006/01/06 16:03:34 $                   LUA(1)
Impressum