lua-users home
lua-l archive

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


On Sat, May 29, 2010 at 09:27, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
>> Yes, use os.getenv(varname) like os.getenv("windir") or os.getenv("home")
>> on Linux.
>
> Or automagically with
>
>        setmetatable(_G,{__index=function (t,i) return os.getenv(i) end})
>        print(home)
>
>

...Which is a terrible idea, basically emulating PHP's
REGISTER_GLOBALS that has lead to so many security issues over the
years.

Now, you could create a table like os.env or similar for that purpose,
or maybe even modify the index function to use a prefix
("print(os_home)"), but don't go messing with the global metatable
like that (especially without considering what's already in it).

-- 
Sent from my toaster.