Bug 289959 - cp(1): Confusing instructions whether -P requires -R
Summary: cp(1): Confusing instructions whether -P requires -R
Status: Closed FIXED
Alias: None
Product: Documentation
Classification: Unclassified
Component: Manual Pages (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Warner Losh
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-10-02 09:44 UTC by Marián Černý
Modified: 2026-07-17 07:06 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marián Černý 2025-10-02 09:44:07 UTC
The manual page for cp command states:

> -P    No symbolic links are followed.  This is the default if the -R option is specified.

and then later

> The -H, -L and -P options are ignored unless the -R option is specified.

However, it clearly works even without -R:

    touch /tmp/file
    ln -s /tmp/file /tmp/symlink
    cp -P /tmp/symlink /tmp/copy

... results in symlink /tmp/copy -> /tmp/file
Comment 1 Marián Černý 2025-10-02 09:56:48 UTC
This inconsistency has been introduced in commit

cp: Make -P work without -R as per POSIX
https://github.com/freebsd/freebsd-src/commit/97e13037915c22162f199461f56951793d669f57

So the note that -P is ignored unless -R is specified should be rephrased.

Note that the following sentence follows:
> In addition, these options override each other and the command's actions are determined by the last one specified.

So maybe the following fix would work:
> The -H and -L options are ignored unless the -R option is specified.
> In addition, the options -H, -L and -P override each other and the
> command's actions are determined by the last one specified.

(Tested with `cp -P -H /tmp/symlink /tmp/copy`... it does not result in symlink.)

See also:
https://reviews.freebsd.org/D30012
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=199466
Comment 2 commit-hook freebsd_committer freebsd_triage 2026-06-10 12:36:32 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=2c5fd7d9a7ed36cf15dd538d9533e7835c7f8555

commit 2c5fd7d9a7ed36cf15dd538d9533e7835c7f8555
Author:     Kit Dallege <xaum.io@gmail.com>
AuthorDate: 2026-03-27 04:25:44 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2026-06-10 12:35:03 +0000

    cp(1): fix -P documentation to reflect it works without -R

    Since commit 97e13037915c, the -P flag works without -R as
    required by POSIX. Update the man page to state that only -H
    and -L are ignored without -R, while -P can be used independently.

    PR: 289959
    Signed-off-by: Kit Dallege <xaum.io@gmail.com>
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/2102

 bin/cp/cp.1 | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2026-07-17 07:06:28 UTC
^Triage: since there is no way to set MFC flags for Manual Pages, there is
nothing to do here but close this.