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

lua, version

Solution

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.

Problem

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 ?

Original source

Related problems