LUA(1)

πŸ“¦
version 5.1.5 Β· 2 versions
  • 5.1.5 Β· alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 5.1.5 Β· opensuse-leap 16.0
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– 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 statement stat. You need to quote stat if it contains spaces, quotes, or other characters special to the shell.
  • -i β€” enter interactive mode after script is executed. Bestie wants to keep talking. 🫢
  • -l name β€” call require('name') before executing script. 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. βœ¨πŸ¦‹