> Date: Fri, 19 Oct 2007 20:12:26 +0200 > From: Paul de Weerd <[EMAIL PROTECTED]> > Subject: Re: : cp(1) bug ? > > On Fri, Oct 19, 2007 at 01:52:03PM -0400, Douglas A. Tutty wrote: > | Conceptually, though, why can't cp look at the source directory and take a > | snapshot, a to-do-list, of everything it has to copy, then do it? That > | way, any recursion would be completed before the target directory > | appeared in the source directory. With only an -R (no -H -L or -P), it > | should copy links as links which should avoid loops. > > What will you do if the underlying directory structure has tons and > tons of files and subdirectories ? First traverse this entire tree, > keeping it all in memory ? Sounds pretty expensive.
I believe that it is only necessary to do one directory read ahead in order to avoid the recursive loop. (I just took a quick look at the cp source in OpenBSD, so, correct me if I am wrong.) $ cp <source1> ... <sourceN> <directory> We can read the contents of <source1> if source1 is a directory, then create a directory in <directory> and copy the contents of source1 into it, and then repeat. This should not cause an endless loop. -- ((name "Aaron Hsu") (email/xmpp "[EMAIL PROTECTED]") (phone "703-597-7656") (site "http://www.aaronhsu.com")) [demime 1.01d removed an attachment of type application/pgp-signature]