correction: hard links are not allowed on directory's, ...
that being said, comparing inodes seems the best solution
only, don't give an error but copy once
maybe if I have time this weekend I'll try code that behaviour
Anyway, it has worked like that since years, and I guess nobody has had
a problem with it before. I don't think it should be changed just
because some bored guy playing with it noticed strange output ;-p
Regards,
Tom
Richard Toohey wrote:
quoted text > On 19/10/2007, at 8:12 PM, Raimo Niskanen wrote:
>
>> On Thu, Oct 18, 2007 at 10:06:42PM +1300, Richard Toohey wrote:
>>> JUST FOR FUN I have tried to "fix" this. What I know about C code
>>> can be written on the back of a postage stamp
>
> Did I mention the SIZE of the postage stamp? It's rather small ... 8-)
>
>> I am afraid solving the general case is harder.
>
>> The path length limit actually works as a crude, cheep and effective
>> cycle detection.
>>
>> While Windows Finder solves the simple case of copying into
>> yourself, I do not think it has solved the general case.
>> Anyone curious to try?
>
> Runs screaming into the night ... A lot more man reading for me, first!
>
>>
>> --
>> / Raimo Niskanen, Erlang/OTP, Ericsson AB
>
> I might try a Linux install (got some Slackware 12.0 CDs) and look at
> what it does (and its source code) - sure someone will beat me to it.
>
> Looks like OpenBSD, FreeBSD, and Mac OS X BSD bits have the same
> sort of outcome.
>
> I got this from Tom Van Looy (thanks, Tom):
>
> Copy foo to foo only once and quit, I think that's the correct
> behaviour. I even think that posix more or less describes that.
>
> $ mkdir foo
> $ cp -R foo foo
> $ ls -R foo
> foo/:
> foo
>
> foo/foo:
>
> That's what it should be doing I guess. But it's tricky, if you start
> doing symlinks etc, you'll end up looping sooner or later. What if the
> directoy's are not named the same (eg: hard links)?
>
> (please reply cc to the list)
>
> And another email from Tom Van Looy:
>
> Oh and yes, it doesn't go boom, the copy just stops when the max
> filename length is reached (logically). And " name too long
> (not copied)" is an error, you can just redirect it to dev null, cp -R
> foo foo 2>/dev/null, if you don't like it on your screen.
>
> Try fixing it so that it doesn't copy a directory into itself when it is
> allready copied (so allow it only once). GNU cp does something like that:
>
> $ mkdir foo
> $ cp -R foo foo
> cp: cannot copy a directory, `foo', into itself, `foo/foo'
> $ ls -R foo
> foo:
> foo
>
> foo/foo:
>
> Only, I think the warning is not needed (and I didn't further test it,
> so it's possibly doing something else after all).