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
F131938478: D51100.diff
Sun, Oct 12, 8:43 AM
Unknown Object (File)
Sep 12 2025, 6:21 AM
Unknown Object (File)
Sep 11 2025, 5:21 AM
Unknown Object (File)
Sep 9 2025, 6:31 AM
Unknown Object (File)
Sep 6 2025, 5:25 PM
Unknown Object (File)
Sep 5 2025, 3:20 PM
Unknown Object (File)
Sep 3 2025, 7:03 AM
Unknown Object (File)
Aug 30 2025, 2:41 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