Page MenuHomeFreeBSD

split(1): auto-extend suffix length if required
ClosedPublic

Authored by jschauma_netmeister.org on Jan 30 2023, 4:54 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 5 2024, 5:44 PM
Unknown Object (File)
Dec 25 2023, 5:12 PM
Unknown Object (File)
Dec 13 2023, 4:18 PM
Unknown Object (File)
Dec 11 2023, 9:02 AM
Unknown Object (File)
Dec 7 2023, 1:50 PM
Unknown Object (File)
Dec 5 2023, 5:52 PM
Unknown Object (File)
Dec 3 2023, 9:48 PM
Unknown Object (File)
Dec 3 2023, 8:49 PM

Details

Reviewers
christos
kevans
Summary

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269250

If the input cannot be split into the number of files resulting from the default suffix length, automatically extend the suffix length rather than bailing out with 'too many files'.

Suffixes are extended such that the resulting files continue to sort lexically and "cat *" would reproduce the input. For example, splitting a 1M lines file into (default) 1000 lines per file would yield files named 'xaa', 'xab', ..., 'xyy', 'xyz', 'xzaaa', 'xzaab', ..., 'xzanl'.

If '-a' is specified, the suffix length is not auto-extended.

This behavior matches GNU sort(1) since around version 8.16.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

LGTM (with the nits fixed).

usr.bin/split/split.1
157

s/given/specified/

usr.bin/split/split.c
400

Style. /* and */ on their own lines.

407

No need for the additional parentheses.

usr.bin/split/split.c
407

Also that line is too long. Each should be 80 columns max.

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