diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-06-15 11:55:47 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-06-15 14:21:10 +0300 |
commit | 02ada52a38576331f58744ffa83d9cbba6b53827 (patch) | |
tree | 0ab02eef86106f7568e6b487719521e3126f5fa9 /bpkg/bpkg.cxx | |
parent | 3a0917dc2e05e8c0a48b12adf19fa2ee9a4a91f8 (diff) |
Use portable environment variable manipulation functions
Diffstat (limited to 'bpkg/bpkg.cxx')
-rw-r--r-- | bpkg/bpkg.cxx | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/bpkg/bpkg.cxx b/bpkg/bpkg.cxx index b9836ad..831b742 100644 --- a/bpkg/bpkg.cxx +++ b/bpkg/bpkg.cxx @@ -4,8 +4,6 @@ #ifndef _WIN32 # include <signal.h> // signal() -#else -# include <stdlib.h> // getenv(), _putenv() #endif #include <cstring> // strcmp() @@ -50,6 +48,12 @@ using namespace std; using namespace butl; using namespace bpkg; +namespace bpkg +{ + int + main (int argc, char* argv[]); +} + // Get -d|--directory value if the option class O has it and empty path // otherwise. Note that for some commands (like rep-info) that allow // specifying empty path, the returned value is a string, not a dir_path. @@ -134,7 +138,7 @@ init (const common_options& co, return o; } -int +int bpkg:: main (int argc, char* argv[]) try { @@ -155,15 +159,15 @@ try // #ifdef _WIN32 { - string mp ("PATH="); - if (const char* p = getenv ("PATH")) + string mp; + if (optional<string> p = getenv ("PATH")) { - mp += p; + mp = move (*p); mp += ';'; } mp += "/bin"; - _putenv (mp.c_str ()); + setenv ("PATH", mp); } #endif @@ -368,3 +372,9 @@ catch (const std::exception& e) return 1; } */ + +int +main (int argc, char* argv[]) +{ + return bpkg::main (argc, argv); +} |