Merge pull request #307098 from r-ryantm/auto-update/cilium-cli
[NixPkgs.git] / pkgs / test / make-binary-wrapper / suffix.c
blobd33f86c070ca5e63f352b9665c0a5281a822a24a
1 #define _GNU_SOURCE /* See feature_test_macros(7) */
2 #include <unistd.h>
3 #include <stdlib.h>
4 #include <assert.h>
5 #include <stdio.h>
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);
11 if (existing) {
12 char *val;
13 assert_success(asprintf(&val, "%s%s%s", existing, sep, suffix));
14 assert_success(setenv(env, val, 1));
15 free(val);
16 } else {
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);