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