[Toybox] xargs "argument too long"

enh enh at google.com
Tue Jul 2 11:26:49 PDT 2019


so you'll not like this...

here's the fix for the xargs tests:

diff --git a/toys/posix/xargs.c b/toys/posix/xargs.c
index 9a3e9dae..244bd471 100644
--- a/toys/posix/xargs.c
+++ b/toys/posix/xargs.c
@@ -76,7 +76,7 @@ static char *handle_entries(char *data, char **entry)
       if (!*s) break;
       save = s;

-      TT.bytes += sizeof(char *);
+//      TT.bytes += sizeof(char *);

       for (;;) {
         if (++TT.bytes >= TT.s && TT.s) return save;

as far as i can tell, GNU xargs isn't counting those bytes. that's the
only way i can make sense of the behavior when i add/subtract one from
the -s argument...

~$ echo -ne 'one \ntwo\n three' | strace -f -e execve xargs -s 13 echo
execve("/usr/bin/xargs", ["xargs", "-s", "13", "echo"], 0x7ffc5d513ea0
/* 64 vars */) = 0
strace: Process 238587 attached
[pid 238587] execve("/bin/echo", ["echo", "one", "two"],
0x7fff0dd5a430 /* 64 vars */) = 0
one two
[pid 238587] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=238587,
si_uid=73769, si_status=0, si_utime=0, si_stime=0} ---
strace: Process 238588 attached
[pid 238588] execve("/bin/echo", ["echo", "three"], 0x7fff0dd5a430 /*
64 vars */) = 0
three
[pid 238588] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=238588,
si_uid=73769, si_status=0, si_utime=0, si_stime=0} ---
+++ exited with 0 +++
~$

_seems_ like a GNU bug, but if no-one's cared/noticed all these years?
plus the BSD xargs on macOS behaves the same as the GNU one, so
there's widespread support for not counting the pointers...



More information about the Toybox mailing list