1 From a8829b10000d33dd08471af6f3f1e2b55f4df6f6 Mon Sep 17 00:00:00 2001
2 From: Cameron Katri <me@cameronkatri.com>
3 Date: Sun, 19 Sep 2021 20:11:20 -0400
4 Subject: [PATCH] cp(1): Make -P work without -R as per POSIX
6 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.
10 bin/cp/cp.1 | 8 ++++----
11 bin/cp/cp.c | 16 ++++++++++------
12 2 files changed, 14 insertions(+), 10 deletions(-)
14 diff --git a/bin/cp/cp.1 b/bin/cp/cp.1
15 index f7e2d639def..c9e62553bc5 100644
19 .\" @(#)cp.1 8.3 (Berkeley) 4/18/94
27 @@ -84,10 +84,10 @@ If the
29 option is specified, all symbolic links are followed.
32 +No symbolic links are followed.
33 +This is the default if the
35 -option is specified, no symbolic links are followed.
41 diff --git a/bin/cp/cp.c b/bin/cp/cp.c
42 index 3a23394df35..d1612003542 100644
45 @@ -99,7 +99,7 @@ main(int argc, char *argv[])
47 struct stat to_stat, tmp_stat;
49 - int Hflag, Lflag, ch, fts_options, r, have_trailing_slash;
50 + int Hflag, Lflag, Pflag, ch, fts_options, r, have_trailing_slash;
53 fts_options = FTS_NOCHDIR | FTS_PHYSICAL;
54 @@ -108,13 +108,14 @@ main(int argc, char *argv[])
71 @@ -123,6 +124,7 @@ main(int argc, char *argv[])
79 @@ -145,7 +147,7 @@ main(int argc, char *argv[])
88 @@ -180,8 +182,10 @@ main(int argc, char *argv[])
89 fts_options |= FTS_LOGICAL;
92 - fts_options &= ~FTS_PHYSICAL;
93 - fts_options |= FTS_LOGICAL | FTS_COMFOLLOW;
95 + fts_options &= ~FTS_PHYSICAL;
96 + fts_options |= FTS_LOGICAL | FTS_COMFOLLOW;
99 (void)signal(SIGINFO, siginfo);