[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: environment variables as modules
- From: Sean Conner <sean@...>
- Date: Mon, 15 Apr 2019 17:19:00 -0400
It was thus said that the Great Soni They/Them L. once stated:
> I'm just gonna leave this here maybe...
>
> table.insert(package.searchers, function(name)
> if os.getenv(name) then
> local f, err = load(os.getenv(name), "=" .. name)
> if not f then error("error loading module from environment
> variable " .. string.format("%q\n\t%s", name, err), 0) end
> return f, name
> else
> return "\n\tno environment variable " .. string.format('%q',
> name)
> end
> end)
>
> local rce = require("QUERY_STRING")
Nice! My replacement for require() [1] even works with it:
_G["package"]["where"]
"QUERY_STRING" table: 0x9a99ce8
"lpeg" table: 0x9aa5500
"org.conman.fsys" table: 0x9aa1318
"org.conman.sys" table: 0x9ab4ce8
"org.conman.syslog" table: 0x9a9fee0
"org.conman.table" table: 0x9af8e68
"org.flummux.keys" table: 0x9a980d8
"org.flummux.luaview" table: 0x9afa4b8
"org.flummux.luaview.viewfunc" table: 0x9aeb1d8
"org.flummux.luaview.viewtab" table: 0x9af9d38
"org.flummux.tty" table: 0x9a9bc10
"org.flummux.ttycore" table: 0x9aa53a8
"org.flummux.xdg" table: 0x9ab5088
---
_G["package"]["where"]["QUERY_STRING"]
1 5
2 "QUERY_STRING"
-spc (Just ignore some of those modules, they're still a work in progress)
[1] Sent in a previous email.