I would like to print a list of all environment variables and their values. I searched the Stackoverflow and the following questions come close but don't answer me:
- How to discover what is available in lua environment? (it's about Lua environment not the system environment variables)
- Print all local variables accessible to the current scope in Lua (again about _G not the os environment variables)
- http://www.lua.org/manual/5.1/manual.html#pdf-os.getenv (this is a good function but I have to know the name of the environment variable in order to call it)
Unlike C, Lua doesn't have envp**
parameter that's passed to main()
so I couldn't find a way to get a list of all environment variables. Does anybody know how I can get the list of the name and value of all environment variables?