Defect report from : Eric Blake , N/A
(Please direct followup comments direct to yyyyyyyyyyyyyy@xxxxxxxxxxxxx)
@ page 0 line 0 section cp objection {ebb.cp}
Problem:
Edition of Specification (Year): 2004
Defect code : 1. Error
The current wording of
http://www.opengroup.org/onlinepubs/009695399/utilities/cp.html, in paragraph 6
of the Description, requires that when using the -R option, "It shall be an
error if target does not exist and more than two operands are specified, or if
target exists and is a file of a type defined by the System Interfaces volume
of IEEE Std 1003.1-2001, but is not a file of type directory." A strict
interpretation of this wording prohibits symbolic links to directories as being
the target of cp -R, because definition 3.163 defines "symbolic link" and
"directory" as two distinct file types.
However, this conflicts with current implementations of cp, which treat a
symlink to a directory as the target argument the same as a directory as the
target:
$ rm -Rf a b c
$ mkdir a
$ ln -s a b
$ cp -RP b c # invocation 1
$ cp -RP b c # invocation 2
Invocation 1 sees that c does not exist, and b is a symlink, so paragraph 5
applies to create the destination name ./c, then step 4.b applies and symlink
./c is created pointing to directory a. Invocation 2 sees that c exists, and
is a file of type symbolic link, so under the current wording, it should print
a diagnostic and return failure with no further action. But many
implementations treat c as a directory, apply paragraph 4 to create the
destination name ./c/b, then step 4.b to create the symbolic link ./c/b (also
visible by the name ./a/b) as a dangling reference to a (since no file by the
name a exists in directory a).
The wording for ln does not have this problem:
http://www.opengroup.org/onlinepubs/009695399/utilities/ln.html Description
paragraph 4 states simply "The second synopsis form shall be assumed when the
final operand names an existing directory." This can be interpreted to include
symbolic links to directories as well as actual directories as the target of a
symbolic link, since both file types name a directory.
Action:
In the Description for cp, change the wordings of paragraphs 2, 4, and 6 as
follows:
... It shall be an error if any source_file is a file of type directory, if
target does not exist, or if target does not name a directory. ...
...
- If target exists and names an existing directory, the name of the
corresponding destination path ...
...
It shall be an error if target does not exist and more than two operands are
specified, or if target exists and does not name a directory.
|