LUA(1)
๐ lua(1) โ from the General Commands Manual
okay bestie, so this is the page for lua, your new fave standalone interpreter. it's filed under General Commands Manual and honestly? iconic. let's get into it โจ
๐ธ NAME
lua โ the Lua interpreter. that's her. that's the whole name. ๐
๐ฆ SYNOPSIS
lua [ options ] [ script [ args ] ]
๐ DESCRIPTION
lua is the standalone Lua interpreter, no cap. she loads and executes Lua programs โ either in textual source form or in precompiled binary form (those precompiled binaries are output by luac, the Lua compiler, iykyk). lua can be used as a batch interpreter and also interactively. dual threat energy fr fr ๐
So here's the flow: after handling the options, the Lua program in file script is 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. When called with no arguments at all, lua behaves as lua -v -i if the standard input is a terminal, and as lua - otherwise. that little auto-detect?? main character behaviour ๐ซถ
In interactive mode, lua prompts you, 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 gets printed. If a line does not contain a complete statement, then a secondary prompt appears and lines are read until a complete statement is formed โ or until a syntax error shows up ๐ญ that's the vibe check failing, bestie.
Before handling command line options and scripts, lua checks the contents of the environment variables LUA_INIT_5_5 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. When LUA_INIT_5_5 is defined, LUA_INIT is ignored. priority order, periodt ๐
โจ OPTIONS โจ
-e statโ execute statement stat. go off, run that line ๐-iโ enter interactive mode after executing script. best of both worlds, honestly ๐ฆ-l modโrequirelibrary mod into global mod. same name in, same name out, no drama โจ-l g=modโrequirelibrary mod into global g. rename her on the way in, slay ๐-vโ show version information. gotta know who you're dealing with ๐-Eโ ignore environment variables. noLUA_INIT, no path vars, nothing. clean slate energy ๐ง-Wโ turn warnings on. let her warn you, she's just looking out ๐ซถ--โ stop handling options. everything after this is not an option, periodt ๐-โ stop handling options and execute the standard input as a file. the tiny hyphen that does two jobs ๐ญ๐ฅ
๐ธ ENVIRONMENT VARIABLES
The following environment variables affect the execution of lua. When defined, the version-specific variants take priority and the version-neutral variants are ignored. like, the specific girlies go first, always ๐
LUA_INIT,LUA_INIT_5_5โ code to be executed before command line options and scripts. the pre-party, the getting-ready playlist ๐LUA_PATH,LUA_PATH_5_5โ initial value ofpackage.path, the path used byrequireto search for Lua loaders. ๐LUA_CPATH,LUA_CPATH_5_5โ initial value ofpackage.cpath, the path used byrequireto search for C loaders. ๐ฅ
โญ EXIT STATUS
If a script calls os.exit, then lua exits with the given exit status. Otherwise, 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. ๐ And here's the cute part: errors raised in interactive mode do not cause exits. she forgives you, bestie ๐ซถ
๐ DIAGNOSTICS
Error messages should be self explanatory. they're not cryptic, they're direct. communication queen โจ
๐ฆ SEE ALSO
luac(1)โ the compiler bestie ๐- The documentation at [lua.org](https://lua.org) โ especially section 7 of the reference manual. go read it, i'm literally begging ๐ธ
๐ AUTHORS
R. Ierusalimschy, L. H. de Figueiredo, W. Celes โ the OGs, the founders, the legends fr fr ๐
lowkey mandatory: everything above is accurate to the letter, bestie โ every flag, every default, every env var. don't come for me if you skipped the -- part ๐
okay and finally, the cute sign-off: this page's source/version is $Date: 2024/03/18 06:57:32 $ ๐ now go write some Lua, you absolute icon ๐
๐ฆ where this page comes from
- arch rolling: lua 5.5.1-1 ยท MIT
- nixos 26.05: lua 5.5.1
- nixpkgs unstable: lua 5.5.1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms