mirror of
https://github.com/ksherlock/mpw.git
synced 2024-11-22 00:32:44 +00:00
load environment from the environment for mpw-shell compatibility.
This commit is contained in:
parent
51a86117b8
commit
c3b235ee95
@ -32,6 +32,9 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
extern char **environ;
|
||||||
|
|
||||||
|
|
||||||
namespace _env_rl {
|
namespace _env_rl {
|
||||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
|
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1050
|
||||||
#define _GETDELIM_GROWBY 128 /* amount to grow line buffer by */
|
#define _GETDELIM_GROWBY 128 /* amount to grow line buffer by */
|
||||||
@ -363,6 +366,25 @@ namespace MPW {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EnvLoadEnv() {
|
||||||
|
/* load from environ */
|
||||||
|
|
||||||
|
for (unsigned i = 0; environ[i]; ++i) {
|
||||||
|
if (memcmp(environ[i], "mpw$", 4)) continue;
|
||||||
|
|
||||||
|
std::string s(environ[i] + 4);
|
||||||
|
auto pos = s.find('=');
|
||||||
|
if (pos == 0) continue;
|
||||||
|
if (pos == s.npos) {
|
||||||
|
MPW::Environment.emplace(std::move(s), "");
|
||||||
|
} else {
|
||||||
|
MPW::Environment.emplace(s.substr(0, pos), s.substr(pos+1));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void EnvLoadFile(const std::string &envfile)
|
void EnvLoadFile(const std::string &envfile)
|
||||||
{
|
{
|
||||||
|
@ -181,6 +181,8 @@ namespace MPW
|
|||||||
{
|
{
|
||||||
void EnvLoadFile(const std::string &envfile);
|
void EnvLoadFile(const std::string &envfile);
|
||||||
void EnvLoadArray(const std::vector<std::string> &data);
|
void EnvLoadArray(const std::vector<std::string> &data);
|
||||||
|
void EnvLoadEnv();
|
||||||
|
|
||||||
|
|
||||||
std::string m(RootDir());
|
std::string m(RootDir());
|
||||||
if (!m.empty())
|
if (!m.empty())
|
||||||
@ -191,6 +193,8 @@ namespace MPW
|
|||||||
Environment.emplace(std::string("MPW"), mm);
|
Environment.emplace(std::string("MPW"), mm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EnvLoadEnv(); // should do this first since it could set MPW??
|
||||||
|
|
||||||
if (defines.size())
|
if (defines.size())
|
||||||
EnvLoadArray(defines);
|
EnvLoadArray(defines);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user