LUA(1)

๐Ÿ“ฆ
version 5.5.1 ยท 4 versions
, in arch rolling, nixos 26.05, nixpkgs unstable

๐Ÿ’œ 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 โ€” require library mod into global mod. same name in, same name out, no drama โœจ
  • -l g=mod โ€” require library 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. no LUA_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 of package.path, the path used by require to search for Lua loaders. ๐ŸŒˆ
  • LUA_CPATH, LUA_CPATH_5_5 โ€” initial value of package.cpath, the path used by require to 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