NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/57253: xargs wraps lines after ~4k characters



The following reply was made to PR bin/57253; it has been noted by GNATS.

From: RVP <rvp%SDF.ORG@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: bin/57253: xargs wraps lines after ~4k characters
Date: Thu, 2 Mar 2023 11:22:48 +0000 (UTC)

 On Thu, 2 Mar 2023, marc%fege.net@localhost wrote:
 
 > I have some very long output lines in various shell scripts needed
 > to be processed by xargs.
 > [...] As long as there is addressable memory available, no
 > command should forcefully ever wrap after a certain amount of line
 > length or stop working on an artificially limit set, even if this
 > limit had a reason in former times.
 >
 
 Well, most Unix systems have _some_ kind of limit on ARG_MAX. On
 Linux it is around 1MB; on FreeBSD it is ~512KB; on NetBSD/amd64
 it is:
 
 $ sysctl -n kern.argmax
 262144
 $
 
 so, that's more that 4KB. And, as long as xargs doesn't _insert_
 a space where there should be none, it's behaving according to
 specs:
 
 ```
 $ cat a.awk
 #!/usr/bin/awk -f
 
 BEGIN {
          cmd = "sysctl -n kern.argmax"
          cmd | getline MAX
          close(cmd)
          for (i = 0; i < MAX * 5; i += length(s)) {
                  s = s "a"
                  print s
          }
 }
 $ chmod u+x a.awk
 $ ./a.awk > 1
 $ ./a.awk | xargs printf '%s\n' > 2
 $ cmp 1 2 && echo OK
 OK
 $
 ```
 
 -RVP
 


Home | Main Index | Thread Index | Old Index