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