summaryrefslogtreecommitdiffstats
path: root/usr.bin/xargs
diff options
context:
space:
mode:
authorasami <asami@FreeBSD.org>1996-03-05 07:43:40 +0000
committerasami <asami@FreeBSD.org>1996-03-05 07:43:40 +0000
commit4a4eedf18c504396660d8c59f813138a1069de04 (patch)
treed5e391fa48031b821beed908cf8a0fc01b06a0ae /usr.bin/xargs
parent024c50eb47f991d3f2a5a532761070d0fde6bd50 (diff)
downloadFreeBSD-src-4a4eedf18c504396660d8c59f813138a1069de04.zip
FreeBSD-src-4a4eedf18c504396660d8c59f813138a1069de04.tar.gz
Make xargs take into account the bytes occupied by the environment.
Original by: peter
Diffstat (limited to 'usr.bin/xargs')
-rw-r--r--usr.bin/xargs/xargs.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c
index e28e840..4d8c071 100644
--- a/usr.bin/xargs/xargs.c
+++ b/usr.bin/xargs/xargs.c
@@ -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) {
OpenPOWER on IntegriCloud