2020-12-26 05:02:38 +00:00
|
|
|
.\" $Id: lua.man,v 1.14 2020/05/21 19:31:21 lhf Exp $
|
|
|
|
.TH LUA 1 "$Date: 2020/05/21 19:31:21 $"
|
2015-03-24 00:00:59 +00:00
|
|
|
.SH NAME
|
|
|
|
lua \- Lua interpreter
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.B lua
|
|
|
|
[
|
|
|
|
.I options
|
|
|
|
]
|
|
|
|
[
|
|
|
|
.I script
|
|
|
|
[
|
|
|
|
.I args
|
|
|
|
]
|
|
|
|
]
|
|
|
|
.SH DESCRIPTION
|
|
|
|
.B lua
|
|
|
|
is the standalone Lua interpreter.
|
|
|
|
It loads and executes Lua programs,
|
|
|
|
either in textual source form or
|
|
|
|
in precompiled binary form.
|
|
|
|
(Precompiled binaries are output by
|
|
|
|
.BR luac ,
|
|
|
|
the Lua compiler.)
|
|
|
|
.B lua
|
|
|
|
can be used as a batch interpreter and also interactively.
|
|
|
|
.LP
|
2020-12-26 05:02:38 +00:00
|
|
|
After handling the
|
|
|
|
.IR options ,
|
2015-03-24 00:00:59 +00:00
|
|
|
the Lua program in file
|
|
|
|
.I script
|
|
|
|
is loaded and executed.
|
2020-12-26 05:02:38 +00:00
|
|
|
The
|
2015-03-24 00:00:59 +00:00
|
|
|
.I args
|
|
|
|
are available to
|
|
|
|
.I script
|
|
|
|
as strings in a global table named
|
2020-12-26 05:02:38 +00:00
|
|
|
.B arg
|
|
|
|
and also as arguments to its main function.
|
|
|
|
When called without arguments,
|
|
|
|
.B lua
|
|
|
|
behaves as
|
|
|
|
.B "lua \-v \-i"
|
|
|
|
if the standard input is a terminal,
|
|
|
|
and as
|
|
|
|
.B "lua \-"
|
|
|
|
otherwise.
|
2015-03-24 00:00:59 +00:00
|
|
|
.LP
|
|
|
|
In interactive mode,
|
|
|
|
.B lua
|
|
|
|
prompts the user,
|
|
|
|
reads lines from the standard input,
|
|
|
|
and executes them as they are read.
|
2020-12-26 05:02:38 +00:00
|
|
|
If the line contains an expression,
|
|
|
|
then the line is evaluated and the result is printed.
|
2015-03-24 00:00:59 +00:00
|
|
|
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.
|
|
|
|
.LP
|
2020-12-26 05:02:38 +00:00
|
|
|
Before handling command line options and scripts,
|
2015-03-24 00:00:59 +00:00
|
|
|
.B lua
|
|
|
|
checks the contents of the environment variables
|
2020-12-26 05:02:38 +00:00
|
|
|
.B LUA_INIT_5_4
|
|
|
|
and
|
2015-03-24 00:00:59 +00:00
|
|
|
.BR LUA_INIT ,
|
|
|
|
in that order.
|
2020-12-26 05:02:38 +00:00
|
|
|
If the contents are of the form
|
2015-03-24 00:00:59 +00:00
|
|
|
.RI '@ filename ',
|
|
|
|
then
|
|
|
|
.I filename
|
|
|
|
is executed.
|
2020-12-26 05:02:38 +00:00
|
|
|
Otherwise, the contents are assumed to be a Lua statement and is executed.
|
|
|
|
When
|
|
|
|
.B LUA_INIT_5_4
|
|
|
|
is defined,
|
|
|
|
.B LUA_INIT
|
|
|
|
is ignored.
|
2015-03-24 00:00:59 +00:00
|
|
|
.SH OPTIONS
|
|
|
|
.TP
|
|
|
|
.BI \-e " stat"
|
|
|
|
execute statement
|
|
|
|
.IR stat .
|
|
|
|
.TP
|
|
|
|
.B \-i
|
|
|
|
enter interactive mode after executing
|
|
|
|
.IR script .
|
|
|
|
.TP
|
|
|
|
.BI \-l " name"
|
2020-12-26 05:02:38 +00:00
|
|
|
require library
|
|
|
|
.I name
|
|
|
|
into global
|
|
|
|
.IR name .
|
2015-03-24 00:00:59 +00:00
|
|
|
.TP
|
|
|
|
.B \-v
|
|
|
|
show version information.
|
|
|
|
.TP
|
|
|
|
.B \-E
|
|
|
|
ignore environment variables.
|
|
|
|
.TP
|
2020-12-26 05:02:38 +00:00
|
|
|
.B \-W
|
|
|
|
turn warnings on.
|
|
|
|
.TP
|
2015-03-24 00:00:59 +00:00
|
|
|
.B \-\-
|
|
|
|
stop handling options.
|
|
|
|
.TP
|
|
|
|
.B \-
|
|
|
|
stop handling options and execute the standard input as a file.
|
2020-12-26 05:02:38 +00:00
|
|
|
.SH ENVIRONMENT VARIABLES
|
|
|
|
The following environment variables affect the execution of
|
|
|
|
.BR lua .
|
|
|
|
When defined,
|
|
|
|
the version-specific variants take priority
|
|
|
|
and the version-neutral variants are ignored.
|
|
|
|
.TP
|
|
|
|
.B LUA_INIT, LUA_INIT_5_4
|
|
|
|
Code to be executed before command line options and scripts.
|
|
|
|
.TP
|
|
|
|
.B LUA_PATH, LUA_PATH_5_4
|
|
|
|
Initial value of package.cpath,
|
|
|
|
the path used by require to search for Lua loaders.
|
|
|
|
.TP
|
|
|
|
.B LUA_CPATH, LUA_CPATH_5_4
|
|
|
|
Initial value of package.cpath,
|
|
|
|
the path used by require to search for C loaders.
|
|
|
|
.SH EXIT STATUS
|
|
|
|
If a script calls os.exit,
|
|
|
|
then
|
|
|
|
.B lua
|
|
|
|
exits with the given exit status.
|
|
|
|
Otherwise,
|
|
|
|
.B lua
|
|
|
|
exits
|
|
|
|
with EXIT_SUCCESS (0 on POSIX systems) if there were no errors
|
|
|
|
and
|
|
|
|
with EXIT_FAILURE (1 on POSIX systems) if there were errors.
|
|
|
|
Errors raised in interactive mode do not cause exits.
|
|
|
|
.SH DIAGNOSTICS
|
|
|
|
Error messages should be self explanatory.
|
2015-03-24 00:00:59 +00:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR luac (1)
|
|
|
|
.br
|
|
|
|
The documentation at lua.org,
|
|
|
|
especially section 7 of the reference manual.
|
|
|
|
.SH AUTHORS
|
|
|
|
R. Ierusalimschy,
|
|
|
|
L. H. de Figueiredo,
|
|
|
|
W. Celes
|
|
|
|
.\" EOF
|