[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.0 and 5.1 together
- From: Diego Nehab <diego@...>
- Date: Tue, 4 Apr 2006 14:25:44 -0400 (EDT)
Hi,
A tricky init-file could do the job either:
[... snip ...]
I agree it would be possible to design an init file that, say,
invoked a version-specific init file. It could look like this:
local function varname(var, version)
return "LUA_" .. version .. "_" .. var
end
local v = string.gsub(_VERSION, "^Lua (%d+)%.(%d+).*$", "%1_%2")
local init = os.getenv(varname("INIT", v))
if init then
if string.sub(init, 1, 1) == '@' then
dofile(string.sub(init, 2))
else
assert(loadstring(init, "=LUA_INIT"))()
end
end
package.path = os.getenv(varname("PATH", v)) or package.path
print(package.path)
package.cpath = os.getenv(varname("CPATH", v)) or package.cpath
print(package.cpath)
What do you think?
Regards,
Diego.