summary refs log blame commit diff
path: root/pkgs/test/make-binary-wrapper/env.c
blob: 89f1f496b34975abef9a9174e9836af7b07d220d (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                                       
// makeCWrapper /hello/world \
    --set PART1 HELLO \
    --set-default PART2 WORLD \
    --unset SOME_OTHER_VARIABLE \
    --set PART3 $'"!!\n"'

#include <unistd.h>
#include <stdlib.h>

int main(int argc, char **argv) {
    putenv("PART1=HELLO");
    setenv("PART2", "WORLD", 0);
    unsetenv("SOME_OTHER_VARIABLE");
    putenv("PART3=\"!!\n\"");
    argv[0] = "/hello/world";
    return execv("/hello/world", argv);
}