aboutsummaryrefslogtreecommitdiff
path: root/findutils/xargs.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-09-26 01:00:15 +0000
committerEric Andersen <andersen@codepoet.org>2000-09-26 01:00:15 +0000
commitd266748c763ccabaa12f200e81531a2f6c4df5f3 (patch)
treea5f76b37546cedfb0eff68bcd34d3363183c517c /findutils/xargs.c
parent53323695c506b9dcf1946f1b26e63e696c74020d (diff)
downloadbusybox-w32-d266748c763ccabaa12f200e81531a2f6c4df5f3.tar.gz
busybox-w32-d266748c763ccabaa12f200e81531a2f6c4df5f3.tar.bz2
busybox-w32-d266748c763ccabaa12f200e81531a2f6c4df5f3.zip
Yet more polish (thanks again to kent robotti for the bug reports).
-Erik
Diffstat (limited to 'findutils/xargs.c')
-rw-r--r--findutils/xargs.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/findutils/xargs.c b/findutils/xargs.c
index beada7a15..433567b77 100644
--- a/findutils/xargs.c
+++ b/findutils/xargs.c
@@ -38,7 +38,7 @@ int xargs_main(int argc, char **argv)
38 char *args = NULL; 38 char *args = NULL;
39 char *cmd_to_be_executed = NULL; 39 char *cmd_to_be_executed = NULL;
40 char traceflag = 0; 40 char traceflag = 0;
41 int len_args=2, len_cmd_to_be_executed, opt; 41 int len_args=0, len_cmd_to_be_executed, opt;
42 pid_t pid; 42 pid_t pid;
43 int wpid, status; 43 int wpid, status;
44 44
@@ -69,8 +69,8 @@ int xargs_main(int argc, char **argv)
69 strcat(cmd_to_be_executed, *argv); 69 strcat(cmd_to_be_executed, *argv);
70 } 70 }
71 71
72 args=xrealloc(args, len_args); 72 //args=xrealloc(args, len_args);
73 strcpy(args, " "); 73// strcpy(args, " ");
74 74
75 /* Now, read in one line at a time from stdin, and store this 75 /* Now, read in one line at a time from stdin, and store this
76 * line to be used later as an argument to the command */ 76 * line to be used later as an argument to the command */
@@ -112,21 +112,23 @@ int xargs_main(int argc, char **argv)
112 in_from_stdin = get_line_from_file(stdin); 112 in_from_stdin = get_line_from_file(stdin);
113 } 113 }
114 114
115 if (traceflag==1) {
116 fprintf(stderr, "%s%s\n", cmd_to_be_executed, args);
117 }
118
119 if ((pid = fork()) == 0) { 115 if ((pid = fork()) == 0) {
120 char *cmd[255]; 116 char *cmd[255];
121 int i=1; 117 int i=1;
122 118
123 //printf("argv[0]='%s'\n", cmd_to_be_executed); 119 if (traceflag==1) {
120 fprintf(stderr, "%s ", cmd_to_be_executed);
121 }
124 cmd[0] = cmd_to_be_executed; 122 cmd[0] = cmd_to_be_executed;
125 while (--argc && ++argv && *argv ) { 123 while (--argc && ++argv && *argv ) {
126 //printf("argv[%d]='%s'\n", i, *argv); 124 if (traceflag==1) {
125 fprintf(stderr, "%s ", *argv);
126 }
127 cmd[i++]=*argv; 127 cmd[i++]=*argv;
128 } 128 }
129 //printf("argv[%d]='%s'\n", i, args); 129 if (traceflag==1) {
130 fprintf(stderr, "%s\n", args);
131 }
130 cmd[i++] = args; 132 cmd[i++] = args;
131 cmd[i] = NULL; 133 cmd[i] = NULL;
132 execvp(cmd_to_be_executed, cmd); 134 execvp(cmd_to_be_executed, cmd);