LUA5.4(1)
π lua β the Lua interpreter, bestie edition π
okay so real talk: this is the manual page for lua, the standalone Lua interpreter, living in the LUA5.4(1) era of the General Commands Manual. yes it's a manpage. no it doesn't have to be boring. let's go π¦
β¨ SYNOPSIS β¨
lua [ options ] [ script [ args ] ]
that's it. that's the whole vibe. options, then optionally a script, then optionally some args for that script. periodt. π
πΈ DESCRIPTION πΈ
lua is the standalone Lua interpreter. it loads and executes Lua programs β either in textual source form or in precompiled binary form. (the precompiled binaries? those come out of luac, the Lua compiler. so luac makes them, lua runs them. iconic duo fr fr.) and lua can be used as a batch interpreter and interactively. versatile queen. π
So here's the flow: after handling the options, the Lua program in file script gets loaded and executed. the args are available to script as strings in a global table named arg β and also as arguments to its main function. two ways in, both valid, we love options.
When you call lua with no arguments at all:
- if the standard input is a terminal, it behaves as
lua -v -i - otherwise, it behaves as
lua -
In interactive mode, lua prompts the user, reads lines from the standard input, and executes them as they are read. if the line contains an expression, then the line is evaluated and the result is printed. if a line doesn't contain a complete statement, then a secondary prompt shows up and lines are read until a complete statement is formed β or until a syntax error is found. π
Important pre-game ritual: before handling command line options and scripts, lua checks the contents of the environment variables LUA_INIT_5_4 and LUA_INIT, in that order. if the contents are of the form '@filename', then filename is executed. otherwise, the contents are assumed to be a Lua statement and get executed. and when LUA_INIT_5_4 is defined, LUA_INIT is ignored. no cap.
π OPTIONS π
-e statβ execute statement stat. just do it. right there. immediately. β-iβ enter interactive mode after executing script. main character energy, but make it a sequel.-l modβrequirelibrary mod into global mod. so it lands in a global with the same name. neat.-l g=modβrequirelibrary mod into global g. now you get to pick the name yourself, custom queen. π-vβ show version information. who am I? what am I? valid questions.-Eβ ignore environment variables. going no-contact with the env, we respect it. π-Wβ turn warnings on. the gentle callouts begin. π«Ά--β stop handling options. everything after is not an option, bestie.-β stop handling options and execute the standard input as a file. two jobs, one tiny dash. π
π¦ ENVIRONMENT VARIABLES π¦
The following environment variables affect the execution of lua. and here's the rule: when defined, the version-specific variants take priority and the version-neutral variants are ignored. so like, pick a lane, versions. π
LUA_INIT,LUA_INIT_5_4β code to be executed before command line options and scripts. the warm-up. the pre-roll. π₯LUA_PATH,LUA_PATH_5_4β initial value ofpackage.path, the path used byrequireto search for Lua loaders. this is where your Lua modules get hunted down. πLUA_CPATH,LUA_CPATH_5_4β initial value ofpackage.cpath, the path used byrequireto search for C loaders. same energy, but for the C side. β¨
π EXIT STATUS π
If a script calls os.exit, then lua exits with the given exit status. otherwise:
- exits with
EXIT_SUCCESS(0 on POSIX systems) if there were no errors - exits with
EXIT_FAILURE(1 on POSIX systems) if there were errors
and one lil caveat that matters: errors raised in interactive mode do not cause exits. the REPL forgives. the REPL forgets. π
π DIAGNOSTICS π
Error messages should be self explanatory. that's the whole section. the errors explain themselves. self-sufficient. independent. we stan a self-explanatory error. π
π SEE ALSO π
luac(1)- The documentation at
lua.orgβ especially section 7 of the reference manual. iykyk. π
π AUTHORS π
R. Ierusalimschy, L. H. de Figueiredo, W. Celes
and that's the page, bestie!! π this was LUA5.4(1) from the General Commands Manual, stamped $Date: 2024/05/08 18:48:27 $, and honestly? iconic. go run some Lua. slay. ππ¦β¨
π¦ where this page comes from
- debian trixie: lua5.4 5.4.7-1+b2 Β· MIT
- opensuse-leap 16.0: lua54 5.4.7-160000.2.2 Β· MIT
- opensuse-leap 16.0: lua54 5.4.7-160000.2.2 Β· MIT
- opensuse-leap 16.0: lua54 5.4.7-160000.2.2 Β· MIT
- opensuse-leap 16.0: lua54 5.4.7-160000.2.2 Β· MIT
- ubuntu questing: lua5.4 5.4.8-1
- ubuntu resolute: lua5.4 5.4.8-1build1 Β· MIT
- ubuntu stonking: lua5.4 5.4.9-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms