Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!eru!luth!sunic!mcsun!hp4nl!phigate!philmds!leo From: leo@philmds.UUCP (Leo de Wit) Newsgroups: comp.unix.wizards Subject: Re: Look! An xargs!! (Re: recursive grep) Message-ID: <1086@philmds.UUCP> Date: 11 Sep 89 10:53:52 GMT References: <666@lakart.UUCP> <1641@cbnewsl.ATT.COM> <7774@cbmvax.UUCP> <16816@pasteur.Berkeley.EDU> <1126@virtech.UUCP> <2404@wyse.wyse.com> <10967@smoke.BRL.MIL> <2415@wyse.wyse.com> <10978@smoke.BRL.MIL> <2205@crdgw1.crd.ge.com> Reply-To: leo@philmds.UUCP (Leo de Wit) Organization: Philips I&E DTS Eindhoven Lines: 27 In article <2205@crdgw1.crd.ge.com> barnett@crdgw1.crd.ge.com (Bruce Barnett) writes: |In article <10978@smoke.BRL.MIL>, gwyn@smoke (Doug Gywn) writes: | |>Why not simply write a genuine xargs implementation, say in C where you |>can do it right without a lot of hassle. | |Hear! hear! | |Who really cares if you can *ALMOST* do it in 35 lines when you can do |it *RIGHT* in 70? | |Forgive this posting of the sources in this newsgroup, but maybe it will |reduce the noise level. Here is the version of xargs.c from comp.sources.whatever [next wrong xargs implementation deleted] This program doesn't handle spaces in arguments correctly. Moreover, since the system() function is used to fire up the command, an (incorrect) re-interpretation of the arguments is done (think of metacharacters like ',\,",$,` etc). This can be dealt with much better by using argv[] directly (and execve(), left as an exercise for the reader). Another bad feature is the use of gets(); I'd like to feed a > BUFSIZ line to your xarrrrrgs. Lastly, your xargs does a poor performance job: the system imposed limit on argument lists is typically much higher than BUFSIZ. Leo.