Page MenuHomeFreeBSD

cp(1): Make -P work without -R as per POSIX
ClosedPublic

Authored by me_cameronkatri.com on Apr 27 2021, 6:25 PM.
Tags
None
Referenced Files
F81607066: D30012.id103146.diff
Thu, Apr 18, 9:09 PM
Unknown Object (File)
Mar 16 2024, 2:03 PM
Unknown Object (File)
Mar 15 2024, 12:56 PM
Unknown Object (File)
Mar 15 2024, 12:55 PM
Unknown Object (File)
Mar 15 2024, 12:54 PM
Unknown Object (File)
Mar 11 2024, 4:56 PM
Unknown Object (File)
Mar 11 2024, 4:56 PM
Unknown Object (File)
Mar 11 2024, 4:56 PM

Details

Summary

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

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

me_cameronkatri.com created this revision.
jbeich set the repository for this revision to rG FreeBSD src repository.

The man page isn't very clear, but the code looks right.

bin/cp/cp.1
90

This isn't quite right.

It's only default if -H or -L aren't specified. This language is also hard to understand.

me_cameronkatri.com added inline comments.
bin/cp/cp.1
90

Hopefully this is better.

Would you like to add some tests to cp_test.sh?

me_cameronkatri.com marked an inline comment as done.

Add a test case.

debdrup added inline comments.
bin/cp/cp.1
35

.Dd needs to be bumped to today.

gbe added a subscriber: gbe.

LGTM for the man page part.

cp [-R [-H | -L | -P]] in the synopsis needs to be changed if -P can be used without -R.

cp [-R [-H | -L | -P]] in the synopsis needs to be changed if -P can be used without -R.

How is that supposed to look? Just move the -P out of the []? But -P still can't be used with -H or -L.

cp [-R [-H | -L | -P]] in the synopsis needs to be changed if -P can be used without -R.

How is that supposed to look? Just move the -P out of the []? But -P still can't be used with -H or -L.

Can -H or -L also be used without -P, or do they require it? What happens it you use 2 (or all 3) of -H, -L, and -P? Latest wins silently? Error? Something else?

cp [-R [-H | -L | -P]] in the synopsis needs to be changed if -P can be used without -R.

How is that supposed to look? Just move the -P out of the []? But -P still can't be used with -H or -L.

Can -H or -L also be used without -P, or do they require it? What happens it you use 2 (or all 3) of -H, -L, and -P? Latest wins silently? Error? Something else?

-H, -L, and -P conflict, the last one specified will silently win. -H and -L require -R, but -P does not.

cp [-R [-H | -L | -P]] in the synopsis needs to be changed if -P can be used without -R.

How is that supposed to look? Just move the -P out of the []? But -P still can't be used with -H or -L.

Can -H or -L also be used without -P, or do they require it? What happens it you use 2 (or all 3) of -H, -L, and -P? Latest wins silently? Error? Something else?

-H, -L, and -P conflict, the last one specified will silently win. -H and -L require -R, but -P does not.

Then I'd go with either a single line:

cp [-R [-H | -L] | -P |-R]]

or two separate lines:

cp [-R [-H | -L]]
cp [-P [-R]]

The latter looks clearer to me.

kevans added a subscriber: kevans.

I will take this; I have further changes in the area.

This revision is now accepted and ready to land.Jan 28 2022, 6:45 AM
This revision now requires review to proceed.Feb 23 2022, 3:26 AM

I will commit this tomorrow afternoon-ish. Thanks! Can you confirm that this is your preferred name + email, please? --author="Cameron Katri <me@cameronkatri.com>"

This revision is now accepted and ready to land.Feb 23 2022, 4:04 AM

I will commit this tomorrow afternoon-ish. Thanks!

Thank you.

Can you confirm that this is your preferred name + email, please? --author="Cameron Katri <me@cameronkatri.com>"

Yes, that's correct.

This revision was automatically updated to reflect the committed changes.