-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Jim Meyering on 3/15/2005 10:35 AM: > > But the actual referent (as opposed to the symlink value) may be > another symlink, which may point to another, etc. The final > non-symlink value -- assuming there is one -- is the referent. > It'd be easy if there were an flink syscall. Then > you'd just open the symlink (which would open the referent) > and use flink to create a hard link to the file behind > the descriptor. > > Is it worth it to make cp manually follow a sequence of symlinks > when given both -L and --link?
On a related matter, POSIX is a bit ambiguous about link utilities when the source is a (nested) symlink. For link(1), it defers strictly to link(2), which does not directly mention what to do if path1 is a symlink. And for ln(1), step 3 states that link(2) should be called "using the object that source_file references as the path1 argument", without saying whether this must be the final referrent (or an error for broken links or loops) or just a single dereference that might be another symlink. Personally, I think that ln(1) should by default always try to resolve the symlink down to a non-symlink file, and error out if that is not possible; and that link(1) should be used to make hard links to symlinks on architectures whose link(2) permit that. Maybe it is also worth adding -H - -L and -P to ln to bypass my proposed default, at the same time as fixing cp -lL. At any rate, the following sequence is a bug in ln(1), because it does not involve any of the above-mentioned ambiguities: $ uname CYGWIN_NT-5.1 $ touch a $ ln -s a b $ ln b c # Bug: c should be a hard link to a, not b $ ls -l a b c - -rw-r--r-- 1 eblake None 0 Mar 15 19:04 a lrwxrwxrwx 2 eblake None 1 Mar 15 19:04 b -> a lrwxrwxrwx 2 eblake None 1 Mar 15 19:04 c -> a - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCN5Zp84KuGfSFAYARAvauAJ9LNWYcbYUdTRM5R2gyl/O9aB0PXwCfV3JJ OwbX0fTnpnDNolsx8R0bPA8= =X51t -----END PGP SIGNATURE----- _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils