Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177589392
D30012.1794806053.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D30012.1794806053.diff
View Options
diff --git a/bin/cp/cp.1 b/bin/cp/cp.1
--- a/bin/cp/cp.1
+++ b/bin/cp/cp.1
@@ -32,7 +32,7 @@
.\" @(#)cp.1 8.3 (Berkeley) 4/18/94
.\" $FreeBSD$
.\"
-.Dd June 6, 2015
+.Dd January 27, 2022
.Dt CP 1
.Os
.Sh NAME
@@ -55,6 +55,14 @@
.Op Fl f | i | n
.Op Fl alpsvx
.Ar source_file ... target_directory
+.Nm
+.Op Fl f | i | n
+.Op Fl alPpsvx
+.Ar source_file target_file
+.Nm
+.Op Fl f | i | n
+.Op Fl alPpsvx
+.Ar source_file ... target_directory
.Sh DESCRIPTION
In the first synopsis form, the
.Nm
@@ -84,10 +92,10 @@
.Fl R
option is specified, all symbolic links are followed.
.It Fl P
-If the
+No symbolic links are followed.
+This is the default if the
.Fl R
-option is specified, no symbolic links are followed.
-This is the default.
+option is specified.
.It Fl R
If
.Ar source_file
diff --git a/bin/cp/cp.c b/bin/cp/cp.c
--- a/bin/cp/cp.c
+++ b/bin/cp/cp.c
@@ -100,22 +100,23 @@
{
struct stat to_stat, tmp_stat;
enum op type;
- int Hflag, Lflag, ch, fts_options, r, have_trailing_slash;
+ int Hflag, Lflag, Pflag, ch, fts_options, r, have_trailing_slash;
char *target;
fts_options = FTS_NOCHDIR | FTS_PHYSICAL;
- Hflag = Lflag = 0;
+ Hflag = Lflag = Pflag = 0;
while ((ch = getopt(argc, argv, "HLPRafilnprsvx")) != -1)
switch (ch) {
case 'H':
Hflag = 1;
- Lflag = 0;
+ Lflag = Pflag = 0;
break;
case 'L':
Lflag = 1;
- Hflag = 0;
+ Hflag = Pflag = 0;
break;
case 'P':
+ Pflag = 1;
Hflag = Lflag = 0;
break;
case 'R':
@@ -124,6 +125,7 @@
case 'a':
pflag = 1;
Rflag = 1;
+ Pflag = 1;
Hflag = Lflag = 0;
break;
case 'f':
@@ -146,7 +148,7 @@
break;
case 'r':
rflag = Lflag = 1;
- Hflag = 0;
+ Hflag = Pflag = 0;
break;
case 's':
sflag = 1;
@@ -181,8 +183,10 @@
fts_options |= FTS_LOGICAL;
}
} else {
- fts_options &= ~FTS_PHYSICAL;
- fts_options |= FTS_LOGICAL | FTS_COMFOLLOW;
+ if (!Pflag) {
+ fts_options &= ~FTS_PHYSICAL;
+ fts_options |= FTS_LOGICAL | FTS_COMFOLLOW;
+ }
}
(void)signal(SIGINFO, siginfo);
diff --git a/bin/cp/tests/cp_test.sh b/bin/cp/tests/cp_test.sh
--- a/bin/cp/tests/cp_test.sh
+++ b/bin/cp/tests/cp_test.sh
@@ -130,6 +130,16 @@
atf_check -e not-empty -s not-exit:0 stat foo/dne/foo
}
+atf_test_case P_flag
+P_flag_body()
+{
+ echo "foo" > bar
+ ln -s bar foo
+
+ atf_check cp -P foo baz
+ atf_check -o inline:'Symbolic Link\n' stat -f %SHT baz
+}
+
atf_init_test_cases()
{
atf_add_test_case basic
@@ -138,4 +148,5 @@
atf_add_test_case matching_srctgt_contained
atf_add_test_case matching_srctgt_link
atf_add_test_case matching_srctgt_nonexistent
+ atf_add_test_case P_flag
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 16, 5:14 AM (20 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41761833
Default Alt Text
D30012.1794806053.diff (2 KB)
Attached To
Mode
D30012: cp(1): Make -P work without -R as per POSIX
Attached
Detach File
Event Timeline