Page MenuHomeFreeBSD

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

Authored by on Feb 13 2023, 2:00 AM.
Referenced Files
Unknown Object (File)
Sun, Jun 30, 11:28 AM
Unknown Object (File)
Jun 7 2024, 11:28 PM
Unknown Object (File)
May 25 2024, 4:31 AM
Unknown Object (File)
May 9 2024, 7:13 PM
Unknown Object (File)
May 8 2024, 4:04 PM
Unknown Object (File)
Apr 30 2024, 10:20 PM
Unknown Object (File)
Mar 13 2024, 3:56 AM
Unknown Object (File)
Feb 18 2024, 8:28 AM



See also:

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

rG FreeBSD src repository
Lint Skipped
Tests Skipped

Event Timeline

christos added inline comments.

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."


Minor nit: {} not really needed.


Again, {} not needed.


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