* lckdo: Now deprecated, since util-linux's flock(1) can do the same
thing.
+ * parallel: -i will now replace {} inside parameters, before the {} had
+ to be a separate parameter.
-- Joey Hess <joeyh@debian.org> Fri, 18 Jun 2010 13:06:47 -0400
char **argv;
int argc = 0;
int i;
+ char *s;
while (command[argc] != 0) {
argc++;
}
- if (replace_cb == 0)
+ if (! replace_cb)
argc++;
argv = calloc(sizeof(char*), argc + nargs);
for (i = 0; i < argc; i++) {
+ while (replace_cb && (s=strstr(command[i], "{}"))) {
+ char *buf=malloc(strlen(command[i]) + strlen(arguments[0]));
+ s[0]='\0';
+ sprintf(buf, "%s%s%s", command[i], arguments[0], s+2);
+ command[i]=buf;
+ }
argv[i] = command[i];
- if (replace_cb && (strcmp(argv[i], "{}") == 0))
- argv[i] = arguments[0];
}
- if (replace_cb == 0)
+ if (! replace_cb)
memcpy(argv + i - 1, arguments, nargs * sizeof(char *));
execvp(argv[0], argv);
exit(1);