LUA5.5(1)

πŸ“¦
version 5.5.1 Β· 2 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– LUA5.5 β€” bestie's guide to the lua interpreter πŸ’–

okay so. this is the manual page for lua, from the General Commands Manual section (section 1, iykyk). it's giving the main character of the Lua world and we're gonna walk through it together, no cap. ✨


🌸 NAME 🌸

lua β€” literally the Lua interpreter. that's her. that's the whole vibe.


πŸŽ€ SYNOPSIS πŸŽ€

lua [ options ] [ script [ args ] ]

so you got your options, you got your script, you got your args. slay.


✨ DESCRIPTION ✨

lua is the standalone Lua interpreter β€” the one that just runs stuff, no compiler drama. it loads and executes Lua programs, and it's flexible about it: either in textual source form or in precompiled binary form. (btw those precompiled binaries are output by luac, the Lua compiler β€” her slightly more serious cousin πŸ’….)

and the way lua can serve cunt in two modes?? it works as a batch interpreter AND it can be interactive. versatility queen. πŸ‘‘

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. so they show up in two places, iconic behavior fr fr.

When called without arguments, lua behaves as lua -v -i if the standard input is a terminal, and as lua - otherwise. (so like, it checks the vibe of your stdin first 🫢)

πŸ¦‹ interactive mode πŸ¦‹

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. (little calculator moment, we love a REPL ✨)

If a line does not contain a complete statement, then a secondary prompt is displayed and lines are read until a complete statement is formed or a syntax error is found. so she'll wait for you to finish your thought. patient bestie energy.

🧚 environment setup before anything else 🧚

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 is executed.
⚠️ When LUA_INIT_5_5 is defined, LUA_INIT is ignored. no overlap. she said one at a time please. πŸ’…

πŸ’… OPTIONS πŸ’…

here's the whole lineup, every single one, bestie. no skips.

  • -e stat β€” execute statement stat. just run the thing right there.
  • -i β€” enter interactive mode after executing script. run first, chat after.
  • -l mod β€” require library mod into global mod. so the module lands in a global with the same name.
  • -l g=mod β€” require library mod into global g. you pick the global name this time, custom queen.
  • -v β€” show version information. a lil flex.
  • -E β€” ignore environment variables. ✨ no env, just vibes ✨
  • -W β€” turn warnings on. she's gonna tell you things now.
  • -- β€” stop handling options. nothing after this gets read as an option.
  • - β€” stop handling options and execute the standard input as a file.

🌈 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. (so the _5_5 ones win, always πŸ†)

  • LUA_INIT, LUA_INIT_5_5 β€” code to be executed before command line options and scripts. it goes first, before literally everything.
  • LUA_PATH, LUA_PATH_5_5 β€” initial value of package.path, the path used by require to search for Lua loaders. this is where she goes looking for your Lua modules πŸ”
  • LUA_CPATH, LUA_CPATH_5_5 β€” initial value of package.cpath, the path used by require to search for C loaders. and this is the C-module hunting ground πŸ”₯

πŸ’€ EXIT STATUS πŸ’€

If a script calls os.exit, then lua exits with the given exit status. she respects your decision, periodt.

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 😭
🌸 but listen: Errors raised in interactive mode do not cause exits. she just moves on. no hard feelings. it's giving resilience.

πŸ™ˆ DIAGNOSTICS πŸ™ˆ

Error messages should be self explanatory. she's not cryptic, she's direct. 😌


🫢 SEE ALSO 🫢

  • luac(1) β€” the compiler bestie
  • The documentation at lua.org, especially section 7 of the reference manual. go read it, it's a whole meal. πŸ“š

πŸ‘‘ AUTHORS πŸ‘‘

R. Ierusalimschy, L. H. de Figueiredo, W. Celes β€” the icons who built her. respect. 🫑


okay that's the whole page, mwah. this version is dated $Date: 2024/03/18 06:57:32 $ and it lives in the General Commands Manual as LUA5.5(1). go run something cute. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from