~kaction/config

ref: bd83900251b2478f4863aa288b5c68d655e63eba config/universe/githooks/run-directory.c -rw-r--r-- 609 bytes
bd839002 — Dmitry Bogatov Recover git-logp script 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char **argv)
{
	const char **args;
	const char *directory;
	int i;
	if (argc < 2) {
		fputs("usage: run-directory <directory> [ARGS ...]\n", stderr);
		return 1;
	}
	directory = argv[1];
	argv++;

	args = malloc(sizeof(char *) * (2 + argc * 2));
	if (!args) {
		fputs("fatal: malloc() failed", stderr);
		return 1;
	}

	i = 0;
	args[i++] = RUN_PARTS;
	while (*++argv) {
		args[i++] = "--arg";
		args[i++] = *argv;
	}
	args[i++] = "--";
	args[i++] = directory;
	args[i++] = NULL;

	return execvp(RUN_PARTS, (char *const *)args);
}