diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-09-25 22:53:05 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-09-25 22:53:05 +0000 |
commit | 3c0595d970b381bdefbd9543a5aebb05814d928e (patch) | |
tree | cf639a03d96c30918c637333f48e7aac8a298aee /findutils/xargs.c | |
parent | 00b6f7a2c0e4a76d49eadfbeda56b4043a1e1bf0 (diff) | |
download | busybox-w32-3c0595d970b381bdefbd9543a5aebb05814d928e.tar.gz busybox-w32-3c0595d970b381bdefbd9543a5aebb05814d928e.tar.bz2 busybox-w32-3c0595d970b381bdefbd9543a5aebb05814d928e.zip |
Some more polish to make xargs act like GNU xargs (thanks to kent robotti
<robotti@metconnect.com> for testing and pointing out the differences)
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@1120 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'findutils/xargs.c')
-rw-r--r-- | findutils/xargs.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/findutils/xargs.c b/findutils/xargs.c index 4a3fe3c60..beada7a15 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=10, len_cmd_to_be_executed, opt; | 41 | int len_args=2, 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,9 +69,11 @@ 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); | ||
73 | strcpy(args, " "); | ||
72 | 74 | ||
73 | /* Now, read in one line at a time from stdin, and stroe this to be used later | 75 | /* Now, read in one line at a time from stdin, and store this |
74 | * as an argument to the command we just stored */ | 76 | * line to be used later as an argument to the command */ |
75 | in_from_stdin = get_line_from_file(stdin); | 77 | in_from_stdin = get_line_from_file(stdin); |
76 | for (;in_from_stdin!=NULL;) { | 78 | for (;in_from_stdin!=NULL;) { |
77 | char *tmp; | 79 | char *tmp; |
@@ -111,8 +113,7 @@ int xargs_main(int argc, char **argv) | |||
111 | } | 113 | } |
112 | 114 | ||
113 | if (traceflag==1) { | 115 | if (traceflag==1) { |
114 | fputs(cmd_to_be_executed, stderr); | 116 | fprintf(stderr, "%s%s\n", cmd_to_be_executed, args); |
115 | fputs(args, stderr); | ||
116 | } | 117 | } |
117 | 118 | ||
118 | if ((pid = fork()) == 0) { | 119 | if ((pid = fork()) == 0) { |