Skip to content

join: compare a missing join field as an empty one - #15875

Merged
cakebaker merged 1 commit into
uutils:mainfrom
costajohnt:fix/join-check-order-15741
Oct 27, 2026
Merged

cakebaker merged 1 commit into
uutils:mainfrom
costajohnt:fix/join-check-order-15741

Conversation

@costajohnt

Copy link
Copy Markdown
Contributor

Input::compare ordered a line that is too short to have the join field before a line whose join field is empty. sort -k gives both the same empty key, so after sort -t, -k2,2 puts x, before y, join -t, -1 2 --check-order stopped with is not sorted: y. Those lines also never paired with each other.

compare now treats a missing field as an empty slice before the usual case-insensitive, locale or byte comparison. The order check, the main loop and State::extend all go through it, so this covers all three. Line::get_field still returns None, so -e filling is unchanged.

Added test_missing_key_is_empty_key in tests/by-util/test_join.rs, covering --check-order with -t,, the self-join pairing, and the default blank separator with a trailing blank. The output matches GNU join run as a black box. It fails on main with join: short:2: is not sorted: y, and all 46 test_join:: tests pass with the fix.

Closes #15741

A line too short to have the join field was ordered before a line whose
join field is empty, while `sort -k` gives both the same empty key. So
`join --check-order` rejected input that `sort -k` had just sorted, and
such lines never paired with each other.

Closes uutils#15741
@cakebaker
cakebaker merged commit 31a4286 into uutils:main Oct 27, 2026
100 checks passed
@cakebaker

Copy link
Copy Markdown
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

join: missing join field sorts before empty one, rejecting sort -k output

2 participants