*** empty log message ***

master
mark 21 years ago
parent db85bdacb5
commit aaef3303e0

@ -0,0 +1,15 @@
-- environment
os.environ
os.setenv(name, value, overwrite)
os.unsetenv(name)
-- miscellaneous
os.sleep(seconds)
-- file system
os.dir
file = os.file
-- process control
pid = os.spawn(filename, {args={}, env={}, stdin=io_file, stdout=io_file, stderr=io_file})
exitcode = os.wait(pid)

@ -0,0 +1,39 @@
local getmetatable, setmetatable = getmetatable, setmetatable
local rawget, rawset, type = rawget, rawset, type
local getenv, setenv, unsetenv = os.getenv, os.setenv, os.unsetenv
local mt = getmetatable(os)
if not mt then
mt = {}
setmetatable(os, mt)
end
module "os"
-- metatable for os
function mt:__index(k)
if k == "environ" then
local environ = {}
-- This function needs to be written in C.
for k,v in getenvs() do
e[k] = v
end
rawset(os, "environ", environ)
end
end
-- metatable for os.environ
mt = {}
function mt:__newindex(name, value)
if type(name) ~= "string" then
error("Expected a string key", 2)
end
if value == nil then
unsetenv(name)
elseif typeof(value) == "string" then
setenv(name, value, true)
else
error("Expected a string value", 2)
end
rawset(self,name,value)
end
environ = setmetatable({}, e)
Loading…
Cancel
Save