]> git.saurik.com Git - redis.git/blob - deps/lua/doc/lua.html
Merge remote-tracking branch 'origin/unstable' into unstable
[redis.git] / deps / lua / doc / lua.html
1 <!-- $Id: lua.man,v 1.11 2006/01/06 16:03:34 lhf Exp $ -->
2 <HTML>
3 <HEAD>
4 <TITLE>LUA man page</TITLE>
5 <LINK REL="stylesheet" TYPE="text/css" HREF="lua.css">
6 </HEAD>
7
8 <BODY BGCOLOR="#FFFFFF">
9
10 <H2>NAME</H2>
11 lua - Lua interpreter
12 <H2>SYNOPSIS</H2>
13 <B>lua</B>
14 [
15 <I>options</I>
16 ]
17 [
18 <I>script</I>
19 [
20 <I>args</I>
21 ]
22 ]
23 <H2>DESCRIPTION</H2>
24 <B>lua</B>
25 is the stand-alone Lua interpreter.
26 It loads and executes Lua programs,
27 either in textual source form or
28 in precompiled binary form.
29 (Precompiled binaries are output by
30 <B>luac</B>,
31 the Lua compiler.)
32 <B>lua</B>
33 can be used as a batch interpreter and also interactively.
34 <P>
35 The given
36 <I>options</I>
37 (see below)
38 are executed and then
39 the Lua program in file
40 <I>script</I>
41 is loaded and executed.
42 The given
43 <I>args</I>
44 are available to
45 <I>script</I>
46 as strings in a global table named
47 <B>arg</B>.
48 If these arguments contain spaces or other characters special to the shell,
49 then they should be quoted
50 (but note that the quotes will be removed by the shell).
51 The arguments in
52 <B>arg</B>
53 start at 0,
54 which contains the string
55 '<I>script</I>'.
56 The index of the last argument is stored in
57 <B>arg.n</B>.
58 The arguments given in the command line before
59 <I>script</I>,
60 including the name of the interpreter,
61 are available in negative indices in
62 <B>arg</B>.
63 <P>
64 At the very start,
65 before even handling the command line,
66 <B>lua</B>
67 executes the contents of the environment variable
68 <B>LUA_INIT</B>,
69 if it is defined.
70 If the value of
71 <B>LUA_INIT</B>
72 is of the form
73 '@<I>filename</I>',
74 then
75 <I>filename</I>
76 is executed.
77 Otherwise, the string is assumed to be a Lua statement and is executed.
78 <P>
79 Options start with
80 <B>'-'</B>
81 and are described below.
82 You can use
83 <B>'--'</B>
84 to signal the end of options.
85 <P>
86 If no arguments are given,
87 then
88 <B>"-v -i"</B>
89 is assumed when the standard input is a terminal;
90 otherwise,
91 <B>"-"</B>
92 is assumed.
93 <P>
94 In interactive mode,
95 <B>lua</B>
96 prompts the user,
97 reads lines from the standard input,
98 and executes them as they are read.
99 If a line does not contain a complete statement,
100 then a secondary prompt is displayed and
101 lines are read until a complete statement is formed or
102 a syntax error is found.
103 So, one way to interrupt the reading of an incomplete statement is
104 to force a syntax error:
105 adding a
106 <B>';'</B>
107 in the middle of a statement is a sure way of forcing a syntax error
108 (except inside multiline strings and comments; these must be closed explicitly).
109 If a line starts with
110 <B>'='</B>,
111 then
112 <B>lua</B>
113 displays the values of all the expressions in the remainder of the
114 line. The expressions must be separated by commas.
115 The primary prompt is the value of the global variable
116 <B>_PROMPT</B>,
117 if this value is a string;
118 otherwise, the default prompt is used.
119 Similarly, the secondary prompt is the value of the global variable
120 <B>_PROMPT2</B>.
121 So,
122 to change the prompts,
123 set the corresponding variable to a string of your choice.
124 You can do that after calling the interpreter
125 or on the command line
126 (but in this case you have to be careful with quotes
127 if the prompt string contains a space; otherwise you may confuse the shell.)
128 The default prompts are "&gt; " and "&gt;&gt; ".
129 <H2>OPTIONS</H2>
130 <P>
131 <B>-</B>
132 load and execute the standard input as a file,
133 that is,
134 not interactively,
135 even when the standard input is a terminal.
136 <P>
137 <B>-e </B><I>stat</I>
138 execute statement
139 <I>stat</I>.
140 You need to quote
141 <I>stat </I>
142 if it contains spaces, quotes,
143 or other characters special to the shell.
144 <P>
145 <B>-i</B>
146 enter interactive mode after
147 <I>script</I>
148 is executed.
149 <P>
150 <B>-l </B><I>name</I>
151 call
152 <B>require</B>('<I>name</I>')
153 before executing
154 <I>script</I>.
155 Typically used to load libraries.
156 <P>
157 <B>-v</B>
158 show version information.
159 <H2>SEE ALSO</H2>
160 <B>luac</B>(1)
161 <BR>
162 <A HREF="http://www.lua.org/">http://www.lua.org/</A>
163 <H2>DIAGNOSTICS</H2>
164 Error messages should be self explanatory.
165 <H2>AUTHORS</H2>
166 R. Ierusalimschy,
167 L. H. de Figueiredo,
168 and
169 W. Celes
170 <!-- EOF -->
171 </BODY>
172 </HTML>