- opt=strlen(*argv);
- len_cmd_to_be_executed = (opt > 10)? opt : 10;
- cmd_to_be_executed = xcalloc(len_cmd_to_be_executed, sizeof(char));
- strcat(cmd_to_be_executed, *argv);
- }
-
-
- /* Now, read in one line at a time from stdin, and stroe this to be used later
- * as an argument to the command we just stored */
- in_from_stdin = get_line_from_file(stdin);
- for (;in_from_stdin!=NULL;) {
- char *tmp;
- opt = strlen(in_from_stdin);
- len_args += opt + 3;
- args=xrealloc(args, len_args);
-
- /* Strip out the final \n */
- in_from_stdin[opt-1]=' ';
-
- /* Replace any tabs with spaces */
- while( (tmp = strchr(in_from_stdin, '\t')) != NULL )
- *tmp=' ';
-
- /* Strip out any extra intra-word spaces */
- while( (tmp = strstr(in_from_stdin, " ")) != NULL ) {
- opt = strlen(in_from_stdin);
- memmove(tmp, tmp+1, opt-(tmp-in_from_stdin));
+ /* concatenate all the arguments passed to xargs together */
+ int i;
+ int len = 1; /* for the '\0' */
+ for (i = 1; i < argc; i++) {
+ len += strlen(argv[i]);
+ len += 1; /* for the space between the args */
+ cmd_to_be_executed = xrealloc(cmd_to_be_executed, len);
+ strcat(cmd_to_be_executed, argv[i]);
+ strcat(cmd_to_be_executed, " ");