Created
September 25, 2020 18:15
-
-
Save deanmsands3/ded4357eb093848c77a7ed9dd658a7b7 to your computer and use it in GitHub Desktop.
Code I used to test my Windows Environment patch for the cpp-subprocess library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
echo "ENV1 = %NEW_ENV1%" | |
echo "ENV2 = %NEW_ENV2%" | |
echo "ENV3 = %NEW_ENV3%" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "subprocess.hpp" | |
using namespace subprocess; | |
void test_env() | |
{ | |
auto p = Popen( | |
"env_script.cmd", | |
environment{ | |
{ | |
{L"NEW_ENV1", L"VALUE-1"}, | |
{L"NEW_ENV2", L"VALUE-2"}, | |
{L"NEW_ENV3", L"VALUE-3"} | |
} | |
}, | |
output{PIPE} | |
); | |
auto obuf=p.communicate().first; | |
std::cout << obuf.buf.data() << std::endl; | |
} | |
int main() { | |
test_env(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment