[BusyBox-cvs] busybox.stable xargs.c,1.23,1.24

Erik Andersen andersen at busybox.net
Wed Aug 6 07:08:23 UTC 2003


Update of /var/cvs/busybox.stable
In directory winder:/tmp/cvs-serv15958

Modified Files:
	xargs.c 
Log Message:
A patch from Alex Zeffertt fixing xargs in busybox 0.60.5:

# echo that | xargs echo this and
and that

The output should be "this and that".


Index: xargs.c
===================================================================
RCS file: /var/cvs/busybox.stable/xargs.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- xargs.c	16 Sep 2002 10:52:29 -0000	1.23
+++ xargs.c	6 Aug 2003 07:08:18 -0000	1.24
@@ -31,7 +31,7 @@
 	char *cmd_to_be_executed;
 	char *file_to_act_on;
 	int i;
-	int len;
+	int len = 0;
 
 	/*
 	 * No options are supported in this version of xargs; no getopt.
@@ -44,14 +44,15 @@
 	 * once with no args and xargs will echo the filename. Simple.
 	 */
 
-	argv++;
-	len = argc;     /* arg = count for ' ' + trailing '\0' */
 	/* Store the command to be executed (taken from the command line) */
 	if (argc == 1) {
 		/* default behavior is to echo all the filenames */
 		argv[0] = "/bin/echo";
+		len++;  /* space for trailing ' ' */
 		len++;  /* space for trailing '\0' */
 	} else {
+        argv++;
+        len = argc;     /* arg = count for ' ' + trailing '\0' */
 		argc--;
 		}
 	/* concatenate all the arguments passed to xargs together */
@@ -59,7 +60,7 @@
 		len += strlen(argv[i]);
 	cmd_to_be_executed = xmalloc (len);
 	for (i = len = 0; i < argc; i++) {
-		len = sprintf(cmd_to_be_executed + len, "%s ", argv[i]);
+		len += sprintf(cmd_to_be_executed + len, "%s ", argv[i]);
 	}
 
 	/* Now, read in one line at a time from stdin, and store this 




More information about the busybox-cvs mailing list