Skip to content

Commit

Permalink
Use helper function
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Nov 8, 2023
1 parent 2ffb5f4 commit a81031c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions include/gz/utils/Subprocess.hh
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Subprocess

this->process = new subprocess_s;

std::vector<std::string> environmentStr;
auto environmentStr = gz::utils::envMapToStrings(this->environment);
std::vector<const char*> environmentCstr;
std::vector<const char*> commandLineCstr;

Expand All @@ -107,10 +107,9 @@ class Subprocess

if (!this->inheritEnvironment)
{
for (const auto &[key, val] : this->environment)
for (const auto &val : environmentStr)
{
environmentStr.push_back(key + "=" + val);
environmentCstr.push_back(environmentStr.back().c_str());
environmentCstr.push_back(val.c_str());
}
environmentCstr.push_back(nullptr);
}
Expand Down

0 comments on commit a81031c

Please sign in to comment.