LUA(1)
π LUA(1) β like, the Lua interpreter bestie π
okay so welcome to lua(1), the main character of the Lua cinematic universe β¨ she's the stand-alone Lua interpreter and she's literally so good at her job.
π¦ SYNOPSIS
lua [ options ] [ script [ args ] ]
πΈ DESCRIPTION
lua is the stand-alone Lua interpreter, no cap. She loads and executes Lua programs β either as textual source code or in precompiled binary form. (The precompiled binaries are output by luac, the Lua compiler, iykyk.) And the way that she can be used as a batch interpreter and interactively? Versatile queen behavior, honestly. π
So here's the vibe: the options you give (they're listed down below, keep scrolling π
) get executed first, and then the Lua program in the file script is loaded and executed. The args you give are available to script as strings in a global table named arg. If those arguments have spaces or other characters that are special to the shell, you gotta quote them β but heads up, the shell is gonna strip those quotes right off. π The arguments in arg start at 0, and index 0 holds the string 'script'. The index of the last argument lives in arg.n. And the arguments you typed on the command line before script β including the name of the interpreter itself β are available at negative indices in arg. Cute, right?
At the very start, before even handling the command line, lua executes the contents of the environment variable LUA_INIT, if it's defined. If the value of LUA_INIT is of the form '@filename', then filename gets executed. Otherwise, the string is assumed to be a Lua statement and gets executed. Either way she's running it fr fr.
Options start with '-' and are described below. You can use '--' to signal the end of options. π
If no arguments are given, then -v -i is assumed when the standard input is a terminal; otherwise, - is assumed.
π§ Interactive mode (the group chat experience)
In interactive mode, lua prompts you, reads lines from the standard input, and executes them as they're read. If a line doesn't contain a complete statement, a secondary prompt shows up and lines keep getting 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 ';' in the middle of a statement is a sure way of forcing a syntax error (except inside multiline strings and comments β those must be closed explicitly, no shortcuts bestie).
If a line starts with '=', then lua displays the values of all the expressions in the remainder of the line. Those expressions must be separated by commas. β
The primary prompt is the value of the global variable _PROMPT, if that value is a string; otherwise, the default prompt is used. Similarly, the secondary prompt is the value of the global variable _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 right on the command line β but in that case you have to be careful with quotes if the prompt string contains a space, otherwise you may confuse the shell. π The default prompts are "> " and ">> ".
β¨ OPTIONS β¨
-β load and execute the standard input as a file, that is, not interactively, even when the standard input is a terminal. She said no chatting today. π-e statβ execute statementstat. You need to quotestatif it contains spaces, quotes, or other characters special to the shell.-iβ enter interactive mode afterscriptis executed. Bestie wants to keep talking. π«Ά-l nameβ callrequire('name')before executingscript. Typically used to load libraries. Very "let me just grab my things first" energy.-vβ show version information. Slay, she's telling you who she is. π
π SEE ALSO
π DIAGNOSTICS
Error messages should be self explanatory. She's not gonna make you guess. π ββοΈ
π AUTHORS
R. Ierusalimschy, L. H. de Figueiredo, and W. Celes β the icons who made all of this happen. π
And that's the whole page bestie!! π This version is dated $Date: 2006/01/06 16:03:34 $ β yeah, she's an OG, been iconic since way back, and she still eats every single time. periodt. β¨π¦
π¦ where this page comes from
- alpine 3.22: lua5.1-doc 5.1.5-r13 Β· MIT
- alpine 3.23: lua5.1-doc 5.1.5-r13 Β· MIT
- alpine 3.24: lua5.1-doc 5.1.5-r13 Β· MIT
- arch rolling: lua51 5.1.5-13 Β· MIT
- debian bookworm: lua5.1 5.1.5-9
- debian trixie: lua5.1 5.1.5-11 Β· MIT
- ubuntu jammy: lua5.1 5.1.5-8.1build4
- ubuntu noble: lua5.1 5.1.5-9build2
- ubuntu questing: lua5.1 5.1.5-11
- ubuntu resolute: lua5.1 5.1.5-12 Β· MIT
- ubuntu stonking: lua5.1 5.1.5-12 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms