There are several points to clear up:
cp is a separate utility from
bash. Some people may be confused by built-in commands such as
pwd which either are or may be part of a POSIX shell.
- POSIX refers to the series of documents jointly maintained by The Open Group and the IEEE, referred to as IEEE Std 1003.1™.
bash is one of several shells which implement the features described in POSIX. Most shells have some differences from the POSIX shell
sh; the name by which the shell is run is a feature described in POSIX.
- in the section 2.14. Special Built-In Utilities, POSIX says
The term "built-in" implies that the shell can execute the utility directly and does not need to search for it. An implementation may choose to make any utility a built-in; however, the special built-in utilities described here differ from regular built-in utilities in two respects:
So in principle
cp could be a part of
bash if its developers had chosen to do that. In practice this is not done because there is no point in further complicating
bash by adding features that can be done well separately from
Next, the link mentioned in the question is based on POSIX, but is not the POSIX document. You can see the disclaimers at the end:
Portions of this text are reprinted and reproduced ...
Any typographical or formatting errors that appear in this page are most likely to have
been introduced during the conversion of the source files to man page format.
But most of the manual page is copied word-for-word from POSIX. POSIX documents are written in a quasi-legalistic style, attempting to avoid describing things in detail where its authors are aware that existing implementations differ, as well as avoid detail where they believe that implementation internal details may differ. So what you get is a step-by-step description of actions that the programs take, and (often) omitting details which other authors would add to explain how the different steps are related. Some of the POSIX documents provide a section for RATIONALE, but even those seem to be a minority. The result is often vague, but you have to make allowances for the intent: describing common features of existing programs.
This is the specific part of the question which indicates confusion:
Given the posix definition, I would expect cp -R srcDir existingDestDir to result in the contents of srcDir to be copied into the existingDestDir. Instead srcDir gets copied into existingDestDir both in bash and csh implementations of sh.
The point of the documentation is that directories in the source are also handled using the same iterative and recursive description as ordinary files. One of the rules is outlined in the Synopsis section:
cp -R [-H|-L|-P] [-fip] source_file... target
which is the third example, and the only one mentioning the
-R option. This is referred to later, in the Description:
The third synopsis form is denoted by two or more operands where the -R option is specified. The
cp utility shall copy each file in the file hierarchy rooted in each source_file to a destination path named as follows:
If target exists and names an existing directory, the name of the corresponding destination path for each file in the file hierarchy shall be the concatenation of target, a single
<slash> character if target did not end in a
<slash>, and the pathname of the file relative to the directory containing source_file.
If target does not exist and two operands are specified, the name of the corresponding destination path for source_file shall be target; the name of the corresponding destination path for all other files in the file hierarchy shall be the concatenation of target, a
<slash> character, and the pathname of the file relative to source_file.
That is, your directory name is treated as a "file" in the first bulleted item, and is concatenated with the target directory's name.
The GNU coreutils manual page lacks detail. You can see some of the flavor of the POSIX document in the Solaris manual page, which by the way is more clearly written:
/usr/bin/cp -r | -R [-H | -L | -P] [-fip@] source_dir... target
In the third synopsis form, one or more directories specified by source_dir are copied to the directory specified by target. Either
-R must be specified. For each source_dir,
cp copies all files and subdirectories.