lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


All of this talk about switching Lua environments reminded me that I
recently released a new version of runlua. Version 20160409 added a new
command-line option, -s, to scan a directory tree for Lua modules.

runlua is a POSIX shell-compatible script that permits you to specify which
Lua implementation (e.g. the API and/or release version, PUC or LuaJIT) to
execute and how to run it (e.g. -t ensures safe threading and -s will update
LUA_PATH, LUA_PATH_5_2, etc). It supports both command-line switches and
shell variables. The most recent version can be downloaded from

	https://github.com/wahern/luapath/blob/master/runlua

runlua can be invoked directly or indirectly through the shebang
interpreter:

	#!/bin/sh
	_=[[
		# ... additional setup here ...
		exec runlua "$0" "$@"
	]]

(But not like #!/path/to/runlua except on Linux and OS X.)

It doesn't currently support LuaRocks, though patches would be welcome.

Usage as described by `runlua -h`:

Usage: runlua [-e:il:vEr:j:Jms:tdpVh] [PATH [...]]
  -e STRING  execute statement
  -i         enter interactive mode after executing PATH
  -l STRING  require package
  -v         print interpreter version information
  -E         ignore environment variables
  -r RANGE   run specific Lua version
  -j RANGE   run specific LuaJIT version
  -J         exclude LuaJIT from candidate interpreters
  -m NUMBER  limit recursion to NUMBER
  -s PATH    scan directory tree for Lua modules
  -t         preload POSIX threading library
  -d         enable debug logging (twice for even more logging)
  -p         print path of Lua interpreter
  -V         print runlua version information
  -h         print this usage message

Examples:
  -r5.2.1    only run PUC Lua 5.2.1 interpreter
  -r5.1      run any Lua 5.1 interpreter, including LuaJIT
  -r5.2-5.3  run any Lua 5.2 or 5.3 interpreter
  -r5.2-     run any Lua 5.2 or later interpreter
  -j2.1      only run LuaJIT 2.1 interpreter

Environment:
  RUNLUA_E=BOOLEAN  same as -E if TRUE
  RUNLUA_R=RANGE    same as -r (use !RANGE to override -r)
  RUNLUA_J=RANGE    same as -j (use !RANGE to override -j or -J)
  RUNLUA_M=NUMBER   same as -m
  RUNLUA_T=BOOLEAN  same as -t if TRUE
  RUNLUA_D=NUMBER   set debug level (e.g. same -dd if 2)
  RUNLUA_P=BOOLEAN  same as -p if TRUE

Examples:
  RUNLUA_R=5.2 runlua           run any Lua 5.2 interpreter
  RUNLUA_R=5.3 runlua -r5.2     same as above (-r has higher precedence)
  RUNLUA_R='!5.3' runlua -r5.2  run any Lua 5.3 interpreter (! overrides -r)

BNF:
  <PATH>    ::= <STRING>
  <RANGE>   ::= <VERSION> | [VERSION] "-" [VERSION]
  <VERSION> ::= <NUMBER> ["." <NUMBER> ["." <NUMBER>]]
  <BOOLEAN> ::= <TRUE> | <FALSE>
  <TRUE>    ::= "yes" | "true" | "1"
  <FALSE>   ::= "no" | "false" | "0" | ""

Report bugs to <william@25thandClement.com>