GNU bug report logs - #33155
cp: copy from symlink -> to symlink?

Previous Next

Package: coreutils;

Reported by: L A Walsh <coreutils <at> tlinx.org>

Date: Thu, 25 Oct 2018 19:59:02 UTC

Severity: wishlist

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: L A Walsh <coreutils <at> tlinx.org>
To: Coreutils <bug-coreutils <at> gnu.org>
Subject: rfe?  cp from symlink -> to symlink? cp symlink meta-info(target)
 with "-a"? (vs. no diagnostic)
Date: Thu, 25 Oct 2018 12:58:20 -0700
Created following test dir (as seen by tree) in /tmp
>  tree mybin
Ishtar:/tmp> tree mybin
mybin
├── iptool -> alt-tool         #broken link
├── iptool-restore -> iptool   #broken link
├── iptool-save -> iptool      #broken link
└── usr
   └── mybin
       ├── alt-tool
       ├── iptool -> alt-tool
       ├── iptool-restore -> iptool
       ├── iptool-save -> iptool
       ├── junka
       ├── junkb
       └── junkc

3 directories, 9 files
----
So first I try copying iptool-save from mybin/usr/mybin to /tmp/mybin

Ishtar:/tmp/mybin/usr/mybin> cp --preserve=all iptool-save /tmp/mybin/
cp: not writing through dangling symlink '/tmp/mybin/iptool-save'

  then try:
Ishtar:/tmp/mybin/usr/mybin> /bin/cp -r --preserve=all -iptool-save 
/tmp/mybin/
(and get no error message)

It seems to have _re_copied the link (time is updated on that link)
but it didn't recursively follow the link and copy the destination.
(nor with -a).  Why did it act as though I said "force" and recopy the
link (unexpected), but didn't recursively follow the link to its target?
(not entirely expected, but wanted).

Especially if I use '-a', shouldn't copying a symlink also copy the
material pointed to -- i.e. duplicated the symlink structure at the target?

One *could* consider the target file "metadata" of the symlink, so at least,
"-a" could cover that case.

It seems odd to silence the diagnostic with "-r" and "-a", but not
recursively follow the link...(I know traditionally -r has referred to
directory structure, but in this case it would be more important & useful
to copy the symlink structure -- ESPECIALLY, since the target symlink
does not exist.  Maybe only overwrite symlink target with "-af"?













This bug report was last modified 6 years and 231 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.