Email List: Xaustin-group-lX
[All Lists]

Re: Re: find + xargs

To: yyyyyyyyyyyyyy@xxxxxxxxxxxxx
Subject: Re: Re: find + xargs
From: "Bill Rugolsky Jr." <yyyyyyyy@xxxxxxxxxxx>
Date: Mon, 26 Mar 2001 12:52:56 -0500
References: <200103261609.LAA09982@raptor.research.att.com>
On Mon, Mar 26, 2001 at 11:09:54AM -0500, David Korn wrote:
> Our current find implementation (the AST software), also supports -print0
> but I would recommend against this since the output format
> is no longer a text file that can be processed by many of the
> standard utilities.
 
True; that is an unfortunate limitation of the SVR4 tools.
It still doesn't solve the cpio issue.
If find, xargs, and cpio can be made safe and useful, why not?

The GNU tools strive to be 8-bit clean and usually support embedded NUL.
A few of the utilities support NUL as a separator, and these are often
sufficient to do real work.  Off the top of my head:

        find        -print0, -fprint0
        xargs       -0
        cpio        -0
        sort        -z    (since on UNIX, -z is an unrelated, deprecated option,
                           it should perhaps be -Z)
        [e]grep    -Z, -z  (for filename and line terminators)
        gawk        8-bit clean.
        tr          preserves NULs (so does /usr/xpg4/bin/tr on Solaris)
        diff       -a forces text comparison

One can also use GNU tr to swap NUL and newline, then swap them back later:

find ... -print0 | tr '\0\n' '\n\0' | ... | tr '\0\n' '\n\0' | ... | xargs -0 
...

Even without Perl, it is clear that solutions to real file-handling problems
(that are potential security holes) are possible with this subset of the
text utilities.

Regards,

    Bill Rugolsky

<Prev in Thread] Current Thread [Next in Thread>