Page MenuHomeFreeBSD

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

Authored by des on Tue, Jul 1, 9:06 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jul 5, 6:08 AM
Unknown Object (File)
Sat, Jul 5, 6:08 AM
Unknown Object (File)
Sat, Jul 5, 6:08 AM
Unknown Object (File)
Sat, Jul 5, 6:08 AM
Unknown Object (File)
Sat, Jul 5, 6:08 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 65143
Build 62026: arc lint + arc unit

Event Timeline

des requested review of this revision.Tue, Jul 1, 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
91

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.Wed, Jul 2, 12:02 AM