2021-10-04 21:35:09 +01:00
|
|
|
// makeCWrapper /hello/world \
|
|
|
|
--set PART1 HELLO \
|
|
|
|
--set-default PART2 WORLD \
|
|
|
|
--unset SOME_OTHER_VARIABLE \
|
|
|
|
--set PART3 $'"!!\n"'
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
2021-12-01 21:49:20 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2021-12-01 21:56:18 +00:00
|
|
|
#define assert_success(e) do { if ((e) < 0) { perror(#e); abort(); } } while (0)
|
2021-10-04 21:35:09 +01:00
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
putenv("PART1=HELLO");
|
2021-12-01 21:49:20 +00:00
|
|
|
assert_success(setenv("PART2", "WORLD", 0));
|
|
|
|
assert_success(unsetenv("SOME_OTHER_VARIABLE"));
|
2021-10-04 21:35:09 +01:00
|
|
|
putenv("PART3=\"!!\n\"");
|
|
|
|
argv[0] = "/hello/world";
|
|
|
|
return execv("/hello/world", argv);
|
|
|
|
}
|