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
Unknown Object (File)
Thu, Oct 24, 2:51 AM
Unknown Object (File)
Wed, Oct 23, 2:52 AM
Unknown Object (File)
Tue, Oct 22, 6:07 PM
Unknown Object (File)
Oct 5 2024, 11:41 AM
Unknown Object (File)
Sep 17 2024, 5:25 PM
Unknown Object (File)
Sep 17 2024, 4:11 AM
Unknown Object (File)
Sep 16 2024, 11:57 AM
Unknown Object (File)
Sep 15 2024, 10:06 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
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 44546
Build 41434: arc lint + arc unit

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.