lua.1 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. .\" $Id: lua.man,v 1.14 2020/05/21 19:31:21 lhf Exp $
  2. .TH LUA 1 "$Date: 2020/05/21 19:31:21 $"
  3. .SH NAME
  4. lua \- Lua interpreter
  5. .SH SYNOPSIS
  6. .B lua
  7. [
  8. .I options
  9. ]
  10. [
  11. .I script
  12. [
  13. .I args
  14. ]
  15. ]
  16. .SH DESCRIPTION
  17. .B lua
  18. is the standalone Lua interpreter.
  19. It loads and executes Lua programs,
  20. either in textual source form or
  21. in precompiled binary form.
  22. (Precompiled binaries are output by
  23. .BR luac ,
  24. the Lua compiler.)
  25. .B lua
  26. can be used as a batch interpreter and also interactively.
  27. .LP
  28. After handling the
  29. .IR options ,
  30. the Lua program in file
  31. .I script
  32. is loaded and executed.
  33. The
  34. .I args
  35. are available to
  36. .I script
  37. as strings in a global table named
  38. .B arg
  39. and also as arguments to its main function.
  40. When called without arguments,
  41. .B lua
  42. behaves as
  43. .B "lua \-v \-i"
  44. if the standard input is a terminal,
  45. and as
  46. .B "lua \-"
  47. otherwise.
  48. .LP
  49. In interactive mode,
  50. .B lua
  51. prompts the user,
  52. reads lines from the standard input,
  53. and executes them as they are read.
  54. If the line contains an expression,
  55. then the line is evaluated and the result is printed.
  56. If a line does not contain a complete statement,
  57. then a secondary prompt is displayed and
  58. lines are read until a complete statement is formed or
  59. a syntax error is found.
  60. .LP
  61. Before handling command line options and scripts,
  62. .B lua
  63. checks the contents of the environment variables
  64. .B LUA_INIT_5_4
  65. and
  66. .BR LUA_INIT ,
  67. in that order.
  68. If the contents are of the form
  69. .RI '@ filename ',
  70. then
  71. .I filename
  72. is executed.
  73. Otherwise, the contents are assumed to be a Lua statement and is executed.
  74. When
  75. .B LUA_INIT_5_4
  76. is defined,
  77. .B LUA_INIT
  78. is ignored.
  79. .SH OPTIONS
  80. .TP
  81. .BI \-e " stat"
  82. execute statement
  83. .IR stat .
  84. .TP
  85. .B \-i
  86. enter interactive mode after executing
  87. .IR script .
  88. .TP
  89. .BI \-l " name"
  90. require library
  91. .I name
  92. into global
  93. .IR name .
  94. .TP
  95. .B \-v
  96. show version information.
  97. .TP
  98. .B \-E
  99. ignore environment variables.
  100. .TP
  101. .B \-W
  102. turn warnings on.
  103. .TP
  104. .B \-\-
  105. stop handling options.
  106. .TP
  107. .B \-
  108. stop handling options and execute the standard input as a file.
  109. .SH ENVIRONMENT VARIABLES
  110. The following environment variables affect the execution of
  111. .BR lua .
  112. When defined,
  113. the version-specific variants take priority
  114. and the version-neutral variants are ignored.
  115. .TP
  116. .B LUA_INIT, LUA_INIT_5_4
  117. Code to be executed before command line options and scripts.
  118. .TP
  119. .B LUA_PATH, LUA_PATH_5_4
  120. Initial value of package.cpath,
  121. the path used by require to search for Lua loaders.
  122. .TP
  123. .B LUA_CPATH, LUA_CPATH_5_4
  124. Initial value of package.cpath,
  125. the path used by require to search for C loaders.
  126. .SH EXIT STATUS
  127. If a script calls os.exit,
  128. then
  129. .B lua
  130. exits with the given exit status.
  131. Otherwise,
  132. .B lua
  133. exits
  134. with EXIT_SUCCESS (0 on POSIX systems) if there were no errors
  135. and
  136. with EXIT_FAILURE (1 on POSIX systems) if there were errors.
  137. Errors raised in interactive mode do not cause exits.
  138. .SH DIAGNOSTICS
  139. Error messages should be self explanatory.
  140. .SH "SEE ALSO"
  141. .BR luac (1)
  142. .br
  143. The documentation at lua.org,
  144. especially section 7 of the reference manual.
  145. .SH AUTHORS
  146. R. Ierusalimschy,
  147. L. H. de Figueiredo,
  148. W. Celes
  149. .\" EOF