summaryrefslogtreecommitdiff
path: root/doc/lua.1
diff options
context:
space:
mode:
Diffstat (limited to 'doc/lua.1')
-rw-r--r--doc/lua.1202
1 files changed, 113 insertions, 89 deletions
diff --git a/doc/lua.1 b/doc/lua.1
index b1561818..c9bba7d7 100644
--- a/doc/lua.1
+++ b/doc/lua.1
@@ -1,137 +1,161 @@
-.\" lua.man,v 1.3 2000/09/04 21:41:28 lhf Exp
-.TH LUA 1 "2000/09/04 21:41:28"
+.\" lua.man,v 1.8 2003/04/02 00:05:20 lhf Exp
+.TH LUA 1 "2003/04/02 00:05:20"
.SH NAME
lua \- Lua interpreter
.SH SYNOPSIS
.B lua
[
-.I arguments
+.I options
+]
+[
+.I script
+[
+.I args
+]
]
.SH DESCRIPTION
.B lua
is the stand-alone Lua interpreter.
It loads and executes Lua programs,
either in textual source form or
-in precompiled binary form,
-as output by
+in precompiled binary form.
+(Precompiled binaries are output by
.BR luac ,
-the Lua compiler.
+the Lua compiler.)
.B lua
can be used as a batch interpreter and also interactively.
.LP
-The
-.I arguments
-can be options, assignments, or filenames,
-and are processed in order,
-from left to right.
+The given
+.I options
+(see below)
+are executed and then
+the Lua program in file
+.I script
+is loaded and executed.
+The given
+.I args
+are available to
+.I script
+as strings in a global table named
+.BR arg .
+If these arguments contain spaces or other characters special to the shell,
+then they should be quoted
+(but note that the quotes will be removed by the shell).
+The arguments in
+.B arg
+start at 0,
+which contains the string
+.RI ` script '.
+The index of the last argument is stored in
+.BR "arg.n" .
+The arguments given in the command line before
+.IR script ,
+including the name of the interpreter,
+are available in negative indices in
+.BR arg .
+.LP
+At the very start,
+before even handling the command line,
+.B lua
+executes the contents of the environment variable
+.BR LUA_INIT ,
+if it is defined.
+If the value of
+.B LUA_INIT
+is of the form
+.RI `@ filename ',
+then
+.I filename
+is executed.
+Otherwise, the string is assumed to be a Lua statement and is executed.
.LP
Options start with
.B \-
and are described below.
-.LP
-An assignment is an argument of the form
-.BR a=b ,
-which assigns the string
-.RB ` b '
-to the global variable
-.BR a .
-Note that no quotes are needed around the string if it does not contain spaces
-or other characters special to the shell.
-This is for convenience only.
-(In general,
-you should be careful when using quotes and spaces on the command line
-because they are usually handled by the shell.)
-.LP
-If the argument is neither an option nor an assignment,
-then it is assumed to be a filename,
-which is then loaded and executed.
+You can use
+.B "\--"
+to signal the end of options.
.LP
If no arguments are given,
then
.B "\-v \-i"
is assumed when the standard input is a terminal;
otherwise,
-.B \-
+.B "\-"
is assumed.
+.LP
+In interactive mode,
+.B lua
+prompts the user,
+reads lines from the standard input,
+and executes them as they are read.
+If a line does not contain a complete statement,
+then a secondary prompt is displayed and
+lines are read until a complete statement is formed or
+a syntax error is found.
+So, one way to interrupt the reading of an incomplete statement is
+to force a syntax error:
+adding a
+.B `;'
+in the middle of a statement is a sure way of forcing a syntax error
+(except inside multiline strings and comments; these must be closed explicitly).
+If a line starts with
+.BR `=' ,
+then
+.B lua
+displays the values of all the expressions in the remainder of the
+line. The expressions must be separated by commas.
+The primary prompt is the value of the global variable
+.BR _PROMPT ,
+if this value is a string;
+otherwise, the default prompt is used.
+Similarly, the secondary prompt is the value of the global variable
+.BR _PROMPT2 .
+So,
+to change the prompts,
+set the corresponding variable to a string of your choice.
+You can do that after calling the interpreter
+or on the command line with
+.BR "_PROMPT" "=\'lua: \'" ,
+for example.
+(Note the need for quotes, because the string contains a space.)
+The default prompts are ``> '' and ``>> ''.
.SH OPTIONS
.TP
.B \-
-load the standard input as a file,
+load and execute the standard input as a file,
that is,
not interactively,
even when the standard input is a terminal.
.TP
-.B \-c
-close Lua before exiting.
-.TP
.BI \-e " stat"
execute statement
.IR stat .
-You will need to quote
+You need to quote
.I stat
-if it contains spaces or quotes.
-.TP
-.BI \-f " file"
-collect all remaining arguments as strings into a global table named
-.B arg
-and then execute
-.IR file .
-The arguments in
-.B arg
-start at 0,
-which contains the string
-.RI ` file '.
-The index of the last argument is stored in
-.BR "arg.n" .
+if it contains spaces, quotes,
+or other characters special to the shell.
.TP
.B \-i
-enter interactive mode,
-displaying a prompt.
-In this mode,
-.B lua
-reads lines from the standard input and executes them as they are read.
-Each line must contain a complete statement.
-To span a statement across several lines, end each line with a backslash
-.BR `\e' .
-The prompt shown is the value of the global variable
-.BR _PROMPT ,
-if this value is a string.
-So,
-to change the prompt,
-set
-.B _PROMPT
-to a string of your choice.
-You can do that after calling the interpreter
-or on the command line with
-.BR "_PROMPT=\'lua: \'" ,
-for example.
-(Note the need for quotes, because the string contains a space.)
-The default prompt is ``> ''.
-.TP
-.B \-q
-enter interactive mode,
-but without displaying a prompt.
+enter interactive mode after
+.I script
+is executed.
.TP
-.BI \-s n
-set the stack size to
-.IB n .
-If present,
-this must be the first option.
-Note that
-.I n
-is in the same argument as
-.BR -s .
-For example,
-to specify a stack size of 2000,
-use
-.BR -s2000 .
+.BI \-l " file"
+call
+.BI require( file )
+before executing
+.IR script.
+Typically used to load libraries
+(hence the letter
+.IR l ).
.TP
.B \-v
-print version information.
+show version information.
.SH "SEE ALSO"
.BR luac (1)
.br
-http://www.tecgraf.puc-rio.br/lua/
+http://www.lua.org/
.SH DIAGNOSTICS
Error messages should be self explanatory.
.SH AUTHORS