diff options
| author | Eric Andersen <andersen@codepoet.org> | 2000-09-25 22:53:05 +0000 |
|---|---|---|
| committer | Eric Andersen <andersen@codepoet.org> | 2000-09-25 22:53:05 +0000 |
| commit | d89882da164d4e4f3506a85f27f3fd2bdd7b810a (patch) | |
| tree | cf639a03d96c30918c637333f48e7aac8a298aee | |
| parent | 3570a34de46b1f7dedd16999bb1687e2d6b55d40 (diff) | |
| download | busybox-w32-d89882da164d4e4f3506a85f27f3fd2bdd7b810a.tar.gz busybox-w32-d89882da164d4e4f3506a85f27f3fd2bdd7b810a.tar.bz2 busybox-w32-d89882da164d4e4f3506a85f27f3fd2bdd7b810a.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
| -rw-r--r-- | findutils/xargs.c | 11 | ||||
| -rw-r--r-- | xargs.c | 11 |
2 files changed, 12 insertions, 10 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) { |
| @@ -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) { |
