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)
Sat, Aug 2, 8:59 PM
Unknown Object (File)
Tue, Jul 29, 5:54 AM
Unknown Object (File)
Tue, Jul 29, 4:18 AM
Unknown Object (File)
Tue, Jul 29, 2:46 AM
Unknown Object (File)
Mon, Jul 28, 10:56 PM
Unknown Object (File)
Sun, Jul 27, 10:52 PM
Unknown Object (File)
Sun, Jul 27, 12:45 PM
Unknown Object (File)
Sun, Jul 27, 8:35 AM
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 65164
Build 62047: 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–114

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