This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lu9.man
132 lines (132 loc) · 2.53 KB
/
lu9.man
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
.TH LU9 1
.SH NAME
lu9 \- Lua standalone for Plan 9
.SH SYNOPSIS
.B lu9
.RB [ -ivw ]
.RI [ script ]
.RI [ args
.IR ... ]
.SH DESCRIPTION
.PP
.I lu9
is an interpreter for Lua as a standalone language.
It runs Lua scripts and provides a basic REPL for
interactive usage.
.PP
In addition to standard Lua libraries it is packed
with several others which are likely to be useful
for writing Plan 9 programs.
This includes the library of bindings for the
.I Plan 9
C library
and the
.IR lpeg
text processing library.
Others are likely to be included in the future,
guided by user demand.
.SH USAGE
.B lu9
runs in script mode by default, loading the
.I script
file if given, or loading the script from standard input
if not.
Given the
.B -i
option an interactive REPL is entered after the script
finishes, or immediately if no script is given.
.PP
A script (a line in interactive mode) is compiled as
a Lua chunk and called with variable number of arguments
.I args
given after the
.I script
on the command line.
The arguments are also loaded into the global
.IR arg
table, with
.B arg[0]
holding the executable (not script) name, and the elements
.B arg[1]
to
.B arg[N]
holding the respective arguments.
.PP
The
.B -w
option turns on the Lua warning system.
.PP
The
.B -v
option prints Lua version and exits.
.SS MODULES
The default
.B package.path
is set to:
.PP
.EX
/sys/lib/lua/5.4/?.lua
/sys/lib/lua/5.4/?/init.lua
\&./?.lua
\&./?/init.lua
.EE
.PP
The
.B package.cpath
does nothing, as dynamically loaded C modules aren't supported.
.SH EXAMPLES
.PP
Run a script with three arguments:
.PP
.EX
; lu9 main.lua a b c
.EE
.PP
Same as above, entering REPL after the script finishes:
.PP
.EX
; lu9 -i main.lua a b c
.EE
.PP
Run REPL with command line arguments:
.PP
.EX
; lu9 -i /dev/null a b c
.EE
.PP
An executable Lua program can be created as expected:
.PP
.EX
; cat /bin/prog
#!/bin/lu9
io.write("hello world\\n")
; chmod +x /bin/prog
; prog
.EE
.SH SEE ALSO
.PP
Lua Reference Manual \- https://lua.org/manual/5.4
.SH SOURCE
.PP
The interpreter and libraries making up the wider "lu9"
project can be found at:
.PP
.EE
https://sr.ht/~kvik/lu9/
.EX
.SH BUGS
.PP
The interpreter interface and runtime environment resembles
but is incompatible with the official
.BR lua (1)
version -- this is largely intentional to keep the code and
runtime behaviour simple. Compatibility features might be
accepted if they prove necessary in practice.
.PP
The Plan 9 libc bindings are WIP.
.PP
There's no way to pre-compile Lua code, as with
.BR luac (1) .
Patches accepted.
.PP
REPL is crude. Patches accepted.