Page MenuHomeFreeBSD

split(1): add '-c' to continue creating files
ClosedPublic

Authored by jschauma_netmeister.org on Feb 13 2023, 2:00 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Mar 13, 3:56 AM
Unknown Object (File)
Feb 18 2024, 8:28 AM
Unknown Object (File)
Jan 5 2024, 5:45 PM
Unknown Object (File)
Dec 25 2023, 5:12 PM
Unknown Object (File)
Dec 22 2023, 9:35 PM
Unknown Object (File)
Dec 13 2023, 4:19 PM
Unknown Object (File)
Dec 7 2023, 11:16 PM
Unknown Object (File)
Dec 5 2023, 8:06 PM

Details

Reviewers
christos
kevans
Summary

See also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269521

diff to split.c, split.1

Currently, split(1) will clobber any existing output files:

$ split file; ls
xaa xab xac xad
$ split second-file; ls
xaa xab xac xad xae xaf

with files 'xaa' - 'xad' now having been overwritten.

I often would like for it to pick up where it left off and continue creating files in the sequence. Right now, there is no good way for me to yield the desired output of "xaa xab xac xad xae xaf xag xah xai xaj".

The attached diff adds a flag "-c" (mnemonic "create, don't overwrite" or "continue where you left off"):

$ split file; ls
xaa xab xac xad
$ split -c second-file; ls
xaa xab xac xad xae xaf xag xah xai xaj

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

christos added inline comments.
usr.bin/split/split.1
174

I think "generate output file names..." is a bit technical and the user typically wouldn't care about the underlying mechanism. It might be better to phrase it as "...will instead create files with names that do not already exist."

usr.bin/split/split.c
354

Minor nit: {} not really needed.

399

Again, {} not needed.

usr.bin/split/split.1
117

You can also mention the mnemonics you have in your description: "create, don't overwrite" or "continue where you left off".

Updated diff to address christos's comments.

(I didn't add the mnemonic comment, since I think the use of "_C_ontinue _c_reating" for the "-c" flag might sufficiently serve as a mnemonic? Seemed odd to specifically add that comment here, but happy to do so if that's preferred.)

Btw, ever since "goto fail" I've made adding braces even for single-line conditionals a habit. Removed that here to match your style, but noting that this does include exactly a "goto fail" (well, "goto again") scenario. ;-)

Please include more context in future diffs; we generally prefer -U999999 (full context), or arc/git-arc will generally DTRT.

This one also LGTM.

This revision is now accepted and ready to land.May 29 2023, 10:45 PM