1 #define _GNU_SOURCE /* See feature_test_macros(7) */
7 #define assert_success(e) do { if ((e) < 0) { perror(#e); abort(); } } while (0)
9 void set_env_suffix(char *env
, char *sep
, char *suffix
) {
10 char *existing
= getenv(env
);
13 assert_success(asprintf(&val
, "%s%s%s", existing
, sep
, suffix
));
14 assert_success(setenv(env
, val
, 1));
17 assert_success(setenv(env
, suffix
, 1));
21 int main(int argc
, char **argv
) {
22 set_env_suffix("PATH", ":", "/usr/bin/");
23 set_env_suffix("PATH", ":", "/usr/local/bin/");
24 argv
[0] = "/send/me/flags";
25 return execv("/send/me/flags", argv
);