bug-coreutils
[Top][All Lists]
Advanced

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

bug#15173: [cp] --link overrides dereference settings


From: Gian Piero Carrubba
Subject: bug#15173: [cp] --link overrides dereference settings
Date: Tue, 5 Nov 2013 01:01:06 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On 11/04/2013 12:48 AM, Bernhard Voelker wrote:
[...]
BUT I'm not happy at all with the following case:

  $ : > file
  $ ln -s file filelink
  $ src/cp --link filelink dst--link
  $ src/cp --link -R filelink dst--link-R
  $ ls -ldogi file filelink dst--link dst--link-R
  537364 -rw-r--r-- 2 0 Nov  4 01:30 dst--link
  537365 lrwxrwxrwx 2 4 Nov  4 01:30 dst--link-R -> file
  537364 -rw-r--r-- 2 0 Nov  4 01:30 file
  537365 lrwxrwxrwx 2 4 Nov  4 01:30 filelink -> file

That's exactly what Gian was worried about in a different case
of my solution: it *matters* whether the rather unrelated -R option
is specified or not. ;-(

Exactly. But this is a problem with the implementation of '-R', and as such I think it should be fixed there. Please see the just-opened bug #15806 [0]. Imho, modifying it here would mean special-casing a special-case. Add we wouldn't gain a lot in terms of consistency ( `cp` dereferences, `cp -R` doesn't, `cp -lR` does ).

[0] http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15806

* [Mon, Nov 04, 2013 at 09:37:07AM +0000] Pádraig Brady:
diff --git a/src/cp.c b/src/cp.c
index 7bc8630..78c0a04 100644
--- a/src/cp.c
+++ b/src/cp.c
@@ -1135,7 +1135,7 @@ main (int argc, char **argv)

   if (x.dereference == DEREF_UNDEFINED)
     {
-      if (x.recursive)
+      if (x.recursive && ! x.hard_link)
         /* This is compatible with FreeBSD.  */
         x.dereference = DEREF_NEVER;
       else

Yes I didn't consider -R in the table as I don't see any reason
for it to behave differently when -l is specified (and -l aplies
neither to POSIX or BSD (comment)).  So the above adjustment
looks correct to me.

Not sure I've understood what you mean here. If '-R' should act the same when '-l' is specified, the above change should _not_ be applied. But I probably misunderstood.

Ciao,
Gian Piero.






reply via email to

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