Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F115705707
D30012.id100478.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D30012.id100478.diff
View Options
Index: bin/cp/cp.1
===================================================================
--- bin/cp/cp.1
+++ bin/cp/cp.1
@@ -32,7 +32,7 @@
.\" @(#)cp.1 8.3 (Berkeley) 4/18/94
.\" $FreeBSD$
.\"
-.Dd June 6, 2015
+.Dd December 22, 2021
.Dt CP 1
.Os
.Sh NAME
@@ -84,10 +84,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
Index: bin/cp/cp.c
===================================================================
--- bin/cp/cp.c
+++ bin/cp/cp.c
@@ -99,22 +99,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':
@@ -123,6 +124,7 @@
case 'a':
pflag = 1;
Rflag = 1;
+ Pflag = 1;
Hflag = Lflag = 0;
break;
case 'f':
@@ -145,7 +147,7 @@
break;
case 'r':
rflag = Lflag = 1;
- Hflag = 0;
+ Hflag = Pflag = 0;
break;
case 's':
sflag = 1;
@@ -180,8 +182,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);
Index: bin/cp/tests/cp_test.sh
===================================================================
--- bin/cp/tests/cp_test.sh
+++ bin/cp/tests/cp_test.sh
@@ -57,8 +57,19 @@
check_size trunc 0
}
+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
atf_add_test_case chrdev
+ atf_add_test_case P_flag
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Apr 28, 10:32 AM (14 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17828932
Default Alt Text
D30012.id100478.diff (2 KB)
Attached To
Mode
D30012: cp(1): Make -P work without -R as per POSIX
Attached
Detach File
Event Timeline
Log In to Comment