[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#11427: cp 8.16 not writing through, writing over
From: |
Jim Meyering |
Subject: |
bug#11427: cp 8.16 not writing through, writing over |
Date: |
Mon, 07 May 2012 19:05:18 +0200 |
Karl Berry wrote:
> Create dangling symlink:
> $ ln -s foo bar
>
> Attempt to write over it with cp:
> $ \cp -i /etc/issue bar
> cp: not writing through dangling symlink 'bar'
>
> In the past, it would ask me if I wanted to replace bar. (As desired.)
Hi Karl,
When I try that in an empty directory and using coreutils-6.7's cp
(which predates the change mentioned below), it does this:
$ ln -s foo bar
$ env cp -i /etc/issue bar :
cp: cannot create regular file `bar': File exists
Maybe you want to use --backup?
> The error message makes me think that it is thinking I am writing
> "through" a dangling symlink to a directory. But that gets
> a different error message, which seems fine:
> $ \cp -i /etc/issue bar/baz
> cp: cannot create regular file 'bar/baz': No such file or directory
>
> coreutils 8.16, compiled from original source on CentOS 5.8 (libc 2.5,
> it seems).
[quick answer: set POSIXLY_CORRECT]
That behavior change dates back to 2007.
Here's the NEWS snippet:
* Noteworthy changes in release 6.9.90 (2007-12-01) [beta]
...
** Changes in behavior
cp, by default, refuses to copy through a dangling destination symlink
Set POSIXLY_CORRECT if you require the old, risk-prone behavior.
There's more detail here:
http://git.sv.gnu.org/cgit/coreutils.git/commit/?id=2bdc48121916ab0d7bb7d
and even more on the mailing list just before I made that change.