mastodon: 4.3.1 -> 4.3.2 (#361487)
[NixPkgs.git] / pkgs / test / make-binary-wrapper / add-flags.c
blobd998a5f6f983c1c69a217ef953c584e3cab41fad
1 #include <unistd.h>
2 #include <stdlib.h>
3 #include <assert.h>
5 int main(int argc, char **argv) {
6 char **argv_tmp = calloc(6 + argc + 2 + 1, sizeof(*argv_tmp));
7 assert(argv_tmp != NULL);
8 argv_tmp[0] = argv[0];
9 argv_tmp[1] = "-x";
10 argv_tmp[2] = "-y";
11 argv_tmp[3] = "-z";
12 argv_tmp[4] = "-abc";
13 argv_tmp[5] = "-g";
14 argv_tmp[6] = "*.txt";
15 for (int i = 1; i < argc; ++i) {
16 argv_tmp[6 + i] = argv[i];
18 argv_tmp[6 + argc + 0] = "-foo";
19 argv_tmp[6 + argc + 1] = "-bar";
20 argv_tmp[6 + argc + 2] = NULL;
21 argv = argv_tmp;
23 argv[0] = "/send/me/flags";
24 return execv("/send/me/flags", argv);