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