Page MenuHomeFreeBSD

cp: Add an option to visit sources in order.
AbandonedPublic

Authored by des on Jul 1 2025, 9:06 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, May 24, 4:56 PM
Unknown Object (File)
Sat, May 23, 3:58 PM
Unknown Object (File)
Thu, May 21, 11:35 AM
Unknown Object (File)
Wed, May 20, 8:32 PM
Unknown Object (File)
Wed, May 20, 11:01 AM
Unknown Object (File)
Tue, May 19, 10:58 PM
Unknown Object (File)
Tue, May 19, 4:19 PM
Unknown Object (File)
Tue, May 19, 4:10 PM
Subscribers

Details

Reviewers
kevans
Group Reviewers
Klara
Summary

This adds a --sort option which makes cp pass a comparison function to
FTS, ensuring that sources are visited and traversed in a predictable
order. This will help make certain test cases more reliable.

While here, add GNU-compatible long options where appropriate, fully
switch boolean variables from int to bool, and clean up the manual page
a little.

Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 65165
Build 62048: arc lint + arc unit

Event Timeline

des requested review of this revision.Jul 1 2025, 9:06 AM

I think I'd prefer to add a --stable long option to avoid a collision with coreutils' cp -S; I don't think there's any technical reason we *wouldn't* implement backup files.

I think I'd prefer to add a --stable long option [...]

We don't currently support long options at all in cp...

In D51100#1166709, @des wrote:

I think I'd prefer to add a --stable long option [...]

We don't currently support long options at all in cp...

Sure, but they're not exactly complicated to add and we can follow-up later to add other comptible long options to be nice. getopt_long is nearly a drop-in replacement if you mutate the optstring right.

Ah, didn't have to go all-in long options at first, but that works- thanks! One minor nit.

bin/cp/cp.c
113

Want to avoid the default behavior of permuting non-option args to the end

I don't see myself having any complaints beyond the one noted

This revision is now accepted and ready to land.Jul 2 2025, 12:02 AM