Make xargs take into account the bytes occupied by the environment.

Original by: peter
This commit is contained in:
Satoshi Asami 1996-03-05 07:43:40 +00:00
parent 7bd7ca5023
commit e5009da0f9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=14387

View File

@ -60,14 +60,14 @@ void err __P((const char *, ...));
void run __P((char **));
void usage __P((void));
main(argc, argv)
main(argc, argv, env)
int argc;
char **argv;
char **argv, **env;
{
register int ch;
register char *p, *bbp, *ebp, **bxp, **exp, **xp;
int cnt, indouble, insingle, nargs, nflag, nline, xflag;
char **av, *argp;
char **av, *argp, **ep = env;
/*
* POSIX.2 limits the exec line length to ARG_MAX - 2K. Running that
@ -84,6 +84,10 @@ main(argc, argv)
*/
nargs = 5000;
nline = ARG_MAX - 4 * 1024;
while (*ep) {
/* 1 byte for each '\0' */
nline -= strlen(*ep++) + 1 + sizeof(*ep);
}
nflag = xflag = 0;
while ((ch = getopt(argc, argv, "n:s:tx")) != EOF)
switch(ch) {