Add legacy +POS/-POS handling in sort to pass GNU sort-field-limit test
This change translates GNU’s legacy +POS1 [-POS2] sort key syntax into -k form before clap parsing, gating it by _POSIX2_VERSION to match GNU behavior, and adds by-util tests to ensure acceptance/rejection behavior matches GNU and that the sort-field-limit compatibility test passes.
#9127
GNU testsuite comparison:
Congrats! The gnu test tests/sort/sort-field-limit is no longer failing!
GNU testsuite comparison:
Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/sort/sort-field-limit is no longer failing!
CodSpeed Performance Report
Merging #9501 will degrade performances by 4.51%
Comparing karanabe:test/fix-sort-field-limit (a10c06e) with main (64203e3)
Summary
⚡ 1 improvement
❌ 2 regressions
✅ 124 untouched
⏩ 6 skipped[^skipped]
:warning: Please fix the performance issues or acknowledge them on CodSpeed.
Benchmarks breakdown
| Benchmark | BASE |
HEAD |
Change | |
|---|---|---|---|---|
| ❌ | sort_ascii_c_locale |
21.6 ms | 22.6 ms | -4.51% |
| ⚡ | sort_numeric |
24 ms | 23.5 ms | +2.04% |
| ❌ | tsort_input_parsing_heavy[5000] |
82.1 ms | 83.8 ms | -2.04% |
| [^skipped]: 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. |
GNU testsuite comparison:
Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/sort/sort-field-limit is no longer failing!
GNU testsuite comparison:
Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/sort/sort-field-limit is no longer failing!
@cakebaker Thanks for the review! I've addressed all the comments.
Regarding the test failure, test_tail::test_retry6 stdout does not seem to be related to this change and appears to be failing elsewhere as well.
Could you please take another look?
Congrats! The gnu test tests/sort/sort-field-limit is no longer failing!
Kudos, thanks!