bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ln overwrites newly created files


From: Eric Blake
Subject: Re: ln overwrites newly created files
Date: Tue, 21 Aug 2007 15:51:30 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Philip Rowlands on 8/21/2007 3:30 PM:
> On Tue, 21 Aug 2007, Eric Blake wrote:
> 
>> $ ln -vf a/f b/f c
>> `c/f' => `a/f'
>> `c/f' => `b/f'
>> $ cat c/f
>> 2
>>
>> Oops - we overwrote the just-created c/f with a link to b/f.
> 
> But you told it to, with -f.

But that is exactly what we told cp to do with --remove-destination.  And
strictly speaking, it is also what POSIX requires for 'mv -f', but as you
can see:

$ mkdir a b c
$ echo 1 > a/f
$ echo 2 > b/f
$ mv -fv a/f b/f c
`a/f' -> `c/f'
mv: will not overwrite just-created `c/f' with `b/f'

> Doesn't POSIX require this to succeed?

Only if it also requires the same for mv and cp.  And Jim Meyering has a
pending aardvark with the Austin Group to make sure the next revision of
POSIX allows GNU's behavior: it is nice to rely on the GNU assumption that
cp, ln, and mv should never be able to lose user data due to collisions in
the destination.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGy15i84KuGfSFAYARAltBAKDLXUlLFswzXIDd3WvBTsmOcXi3VgCePsw3
5nXS8vwhL7ki3ROC+Rl47f0=
=+qr+
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]