[EMAIL PROTECTED] writes: > $ mkdir c > $ ln -s c a > $ cp -RPv a b > `a' -> `b' > $ cp -RPv a b > `a' -> `b/a' > > violates POSIX by my reading, since the target 'b' exists and is of type > symlink (not directory).
The POSIX spec says that the -P option affects a "symbolic link specified as a source_file operand or any symbolic link encountered during traversal of a file hierarchy". I interpret the last part of this phrase to be talking about traversal of the source_file hierarchy. If so, the -P option should not affect whether "b" is dereferenced in the early step (before step 1) where POSIX says If target exists and is a file of type directory, the name of the corresponding destination path for each file in the file hierarchy shall be the concatenation of target, a slash character, and the pathname of the file relative to the directory containing source_file. Here, the target b is a symbolic link to a directory; does this count as a directory? Traditionally I think the answer is "yes". > Is this a bug in coreutils, or a weakness in the POSIX specification that > needs to be brought up to the Open Group? The spec could be clearer, yes. > I also found it odd that the --no-dereference option (-n in ln, -P in cp) > behaves differently: The --no-dereference option is in a bit of a wierd state, I'm afraid. It's been on my list of things to look at for a several months now, but I haven't have the time to spend on it. Please see <http://lists.gnu.org/archive/html/bug-coreutils/2004-05/msg00140.html> for some thoughts (but they're not all correct :-). > I already showed that cp -P dereferences a destination symlink to a > directory, even though the similar ln -n does not. Maybe it would make > sense for cp to have: > -n --no-target-dereference Don't dereference target > -P --no-source-dereference Don't dereference sources > --no-dereference Same as -nP An interesting idea... > My intent was to do something like: > LIST='foo_file bar_dir blah/my_file blah/my_dir' > SRC=src > DST=dst > CP='ln -sn' > for file in $LIST; do > $CP ${SRC}/$file ${DST}/$file > done Have you looked into the new --no-target-directory (-T) option? It would appear to do what you want. It's in CVS coreutils. _______________________________________________ Bug-coreutils mailing list [EMAIL PROTECTED] http://lists.gnu.org/mailman/listinfo/bug-coreutils
