Bug 199466

Summary: cp(1) should accept -P without -R as well per POSIX.1-2008 or like GNU cp
Product: Base System Reporter: Jan Beich <jbeich>
Component: standardsAssignee: Kyle Evans <kevans>
Status: Closed FIXED    
Severity: Affects Only Me CC: emaste, kevans, me+fbsd, standards
Priority: --- Flags: kevans: mfc-stable13+
kevans: mfc-stable12+
Version: CURRENT   
Hardware: Any   
OS: Any   
URL: http://pubs.opengroup.org/stage7tc1/utilities/cp.html
Attachments:
Description Flags
cp(1): Make -P work independantly of -R none

Description Jan Beich freebsd_committer freebsd_triage 2015-04-15 13:06:55 UTC
2013 edition clarifies the meaning of -P outside of -R context, mainly

  cp [-Pfip] source_file target_file
  cp [-Pfip] source_file... target

  If the -R option was not specified, cp shall take actions based on the type and contents of the file referenced by the symbolic link, and not by the symbolic link itself, unless the -P option was specified.

Note, in GNU cp -P (--no-dereference) always worked outside of -R (--recursive).
http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=c93a607
Comment 1 Cameron Katri 2021-04-21 19:28:55 UTC
Created attachment 224339 [details]
cp(1): Make -P work independantly of -R

This patch should fix it.
Comment 2 Cameron Katri 2021-04-27 18:27:16 UTC
I forgot to update the date in the manpage in my previous patch, here is one with that fixed, https://reviews.freebsd.org/D30012.
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-02-23 18:59:16 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=97e13037915c22162f199461f56951793d669f57

commit 97e13037915c22162f199461f56951793d669f57
Author:     Cameron Katri <me@cameronkatri.com>
AuthorDate: 2022-02-23 18:55:13 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2022-02-23 18:55:13 +0000

    cp: Make -P work without -R as per POSIX

    According to POSIX, cp should allow the `-P` flag to work whether `-R`
    is specified or not.  Currently, the `-P` option only works along with
    `-R`.

    PR:             199466
    Reviewed by:    kevans
    Differential Revision:  https://reviews.freebsd.org/D30012

 bin/cp/cp.1             | 16 ++++++++++++----
 bin/cp/cp.c             | 13 ++++++++-----
 bin/cp/tests/cp_test.sh | 11 +++++++++++
 3 files changed, 31 insertions(+), 9 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2022-03-09 21:23:03 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=44eb8cfdc69bb31f11293a8d4f6f36b608887b64

commit 44eb8cfdc69bb31f11293a8d4f6f36b608887b64
Author:     Cameron Katri <me@cameronkatri.com>
AuthorDate: 2022-02-23 18:55:13 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2022-03-09 21:22:02 +0000

    cp: Make -P work without -R as per POSIX

    According to POSIX, cp should allow the `-P` flag to work whether `-R`
    is specified or not.  Currently, the `-P` option only works along with
    `-R`.

    PR:             199466

    (cherry picked from commit 97e13037915c22162f199461f56951793d669f57)

 bin/cp/cp.1             | 16 ++++++++++++----
 bin/cp/cp.c             | 13 ++++++++-----
 bin/cp/tests/cp_test.sh | 11 +++++++++++
 3 files changed, 31 insertions(+), 9 deletions(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2022-04-25 00:04:12 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=19413ce66cc02d676e0778eb9519284e47d7d8e1

commit 19413ce66cc02d676e0778eb9519284e47d7d8e1
Author:     Cameron Katri <me@cameronkatri.com>
AuthorDate: 2022-02-23 18:55:13 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2022-04-25 00:02:30 +0000

    cp: Make -P work without -R as per POSIX

    According to POSIX, cp should allow the `-P` flag to work whether `-R`
    is specified or not.  Currently, the `-P` option only works along with
    `-R`.

    PR:             199466
    Reviewed by:    kevans

    (cherry picked from commit 97e13037915c22162f199461f56951793d669f57)

 bin/cp/cp.1             | 16 ++++++++++++----
 bin/cp/cp.c             | 13 ++++++++-----
 bin/cp/tests/cp_test.sh | 11 +++++++++++
 3 files changed, 31 insertions(+), 9 deletions(-)