Skip to content

Instantly share code, notes, and snippets.

@deanmsands3
Created September 25, 2020 18:15
Show Gist options
  • Save deanmsands3/ded4357eb093848c77a7ed9dd658a7b7 to your computer and use it in GitHub Desktop.
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
@echo off
echo "ENV1 = %NEW_ENV1%"
echo "ENV2 = %NEW_ENV2%"
echo "ENV3 = %NEW_ENV3%"
#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