[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Behaviour of cp with symlinks changed
From: |
Jim Meyering |
Subject: |
Re: Behaviour of cp with symlinks changed |
Date: |
Wed, 19 Dec 2007 21:16:11 +0100 |
Ignacio Fernández Galván <address@hidden> wrote:
> I'm sorry if this is not a bug, I didn't find another list to just ask
> general questions...
>
> My problem is the following:
>
> $ ln -sf file1 link1
> $ ln -sf file2 link2
> $ touch file1
> $ cp -p link1 link2
> cp: cannot create regular file `link2': File exists
>
> This happens in a Mandriva 2008 systems (coreutils 6.9), but it didn't
> happen in Mandriva 2007 (as far as I remember) and it doesn't happen in
> another SuSE system with coreutils 5.2.1.
>
> The expected result would be to have file1 copied into file2, through
> the symlinks pointing to them. Is there some other option I have to add
> to cp? I tried several things but they didn't work.
Copying through a destination symlink is fundamentally risky,
so I've changed cp not to do it anymore.
Here's where I announced this change (there's been no feedback):
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/11922
a little more background:
http://bugzilla.redhat.com/243588
Best is just not to do that anymore. However, if it's something
you cannot easily avoid, you can do this instead:
$ cp -p link1 $(readlink -f link2)