NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/37666: xargs: Argument list too long
On Wed, 02 Jan 2008, cheusov%tut.by@localhost wrote:
> xargs: cat: Argument list too long
xargs(1) in NetBSD-current takes the environment into account when
working out how many args it may pass, but xargs(1) in netbsd-4 and
earlier do not. I believe that this is the cause of the problem you
saw.
Please try the appended patch.
--apb (Alan Barrett)
Index: src/usr.bin/xargs/xargs.c
--- xargs.c 28 Mar 2006 14:27:41 -0000 1.15
+++ xargs.c 7 Jan 2008 08:38:49 -0000
@@ -69,13 +69,15 @@
int main __P((int, char **));
static void usage __P((void));
+extern char **environ;
+
int
main(argc, argv)
int argc;
char **argv;
{
int ch;
- char *p, *bbp, *ebp, **bxp, **exp, **xp;
+ char *p, *bbp, *ebp, **bxp, **exp, **xp, **ep;
int cnt, indouble, insingle, nargs, nflag, nline, xflag;
long arg_max;
char **av, *argp;
@@ -99,6 +101,9 @@
if ((arg_max = sysconf(_SC_ARG_MAX)) == -1)
errx(1, "sysconf(_SC_ARG_MAX) failed");
nline = arg_max - 4 * 1024;
+ for (ep = environ; *ep; ep++) {
+ nline -= strlen(*ep) + 1 + sizeof(*ep);
+ }
nflag = xflag = 0;
while ((ch = getopt(argc, argv, "0n:ps:tx")) != -1)
switch(ch) {
Home |
Main Index |
Thread Index |
Old Index