Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to get lua interpreter version information in script? [duplicate]

Tags:

All I know is how to do it from command line, that is the -v switch.

I need something like phpversion() or sys.version in python. Is that possible ?

like image 326
rsk82 Avatar asked Aug 16 '13 07:08

rsk82


People also ask

What is Lua 5. 4?

Lua 5.4 was released on 29 Jun 2020. Its main new features are a new generational mode for garbage collection and const and to-be-closed variables.

How do I turn off Lua interpreter?

To exit the interactive mode and the interpreter, just type end-of-file ( ctrl-D in Unix, ctrl-Z in DOS/Windows), or call the exit function, from the Operating System library (you have to type os. exit()<enter> ).

What is a Lua command?

The Command Lua API allows users to control behaviour of Command directly by using the Lua scripting language, providing a flexible and easy to use tool for users to extend or customize the built-in functionality of Command.

How is Lua interpreted?

Lua is not directly interpreted through a Lua file like other languages such as Python. Instead, it uses the Lua interpreter to compile a Lua file to bytecode. The Lua interpreter is written in ANSI C, making it highly portable and capable of running on a multitude of devices.

How do I check Lua version?

1 Answer 1. As the duplicate question says, the standard way to get Lua version is: There is another way: calling lua -v directly: Note that io.popen is not portable, but it should work in both Linux and Windows. But for the latter I would need the location of lua executable file.

How to run Lua program in Windows?

The second method is in Windows file explorer, drag .lua file to lua.exe, it will start lua.exe and pass .lua file as a parameter, the same works for .wlua file and wlua.exe. The third method is when you ship the software, compiling the interpreter will lua code file path hard coded.

How to get 3rd digit of ARG in Lua?

If you also need the third digit in Lua version (not available in _VERSION) you need to parse the output of lua -v command on the command line. For platforms that support io.popen this script will do the trick, but only if the script is run by the standalone interpreter (not in interactive mode).IOW the arg global table must be defined:


1 Answers

As the duplicate question says, the standard way to get Lua version is:

print(_VERSION) 

Anyway, _VERSION will contain a string like Lua 5.1, but it's not the same as lua -v, which outputs the whole version information including min version number like Lua 5.1.4

There is another way: calling lua -v directly:

io.popen("lua -v") --Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio 

Note that io.popen is not portable, but it should work in both Linux and Windows.

like image 163
Yu Hao Avatar answered Oct 22 '22 15:10

Yu Hao