-
Notifications
You must be signed in to change notification settings - Fork 7
sort: full -k KEYDEF parsing with start/end fields, character positions, and per-key flags #906
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
sort -k currently only parses a single field number (e.g. -k2 or -k2n). The GNU coreutils key specification is much richer and scripts in the wild rely on it.
Missing features
- End-field specs:
-k2,3(sort by fields 2 through 3) - Character positions:
-k2.3,3.4(start at field 2 char 3, end at field 3 char 4) - Per-key flags:
-k2n,2vs-k3r,3(different sort modes per key) - Multiple keys:
-k1,1 -k2n(primary sort by field 1 lexically, secondary by field 2 numerically)
Current code
sortuniq.rs:137-145 — parses -k value by extracting leading digits and checking for n/r suffix. No comma handling, no multi-key support.
Suggested approach
uutils/coreutils (MIT) has a robust key parser in their sort implementation that handles the full GNU syntax. Consider borrowing or adapting the parsing logic. The comparison/sorting itself can stay as-is since it already works against bashkit's VFS.
References
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request