Subject: bug#33155: rfe? cp from symlink -> to symlink? cp symlink meta-info(target) with "-a"? (vs. no diagnostic)

From: L A Walsh <[email-masked]>
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"?