0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-12 15:08:55 +02:00

modules/console: Add cmd to explore posix env vars.

This commit is contained in:
Jason Volk 2018-09-15 00:48:57 -07:00
parent e6a62b41b3
commit 5b9a6efc54

View file

@ -554,6 +554,53 @@ console_cmd__mem(opt &out, const string_view &line)
return true;
}
//
// env
//
bool
console_cmd__env(opt &out, const string_view &line)
{
if(!::environ)
throw error
{
"Env variable list not available."
};
const params param{line, " ",
{
"key"
}};
if(param["key"] == "*")
{
for(const char *const *e(::environ); *e; ++e)
out << *e << std::endl;
return true;
}
if(param["key"])
{
out << util::getenv(param["key"]) << std::endl;
return true;
}
for(const char *const *e(::environ); *e; ++e)
{
string_view kv[2];
tokens(*e, '=', kv);
if(!startswith(kv[0], "IRCD_") && !startswith(kv[0], "ircd_"))
continue;
out << std::setw(64) << std::left << kv[0]
<< " :" << kv[1]
<< std::endl;
}
return true;
}
//
// conf
//