sort: version_cmp should keep the trailing 0 for comparison#4325
sort: version_cmp should keep the trailing 0 for comparison#4325sylvestre wants to merge 1 commit intouutils:mainfrom sylvestre:fosdem-demo
Conversation
Fix misc/sort-version.sh
|
I wonder if this really addresses the core of the issue. I think the problem is with stable vs unstable sorting: # Without --stable, 04 always comes before 4
❯ echo 04\n4 | sort --sort=version
04
4
❯ echo 4\n04 | sort --sort=version
04
4
# With --stable, the order is preserved
❯ echo 04\n4 | sort --sort=version --stable
4
04
❯ echo 4\n04 | sort --sort=version --stable
04
4I think ❯ echo 4\n04\n4\n04\n04\n04\n4\n4\n04\n04 | sort --sort=version
04
04
04
04
04
04
4
4
4
4 |
|
@tertsdiepraam That's weird. Doesn't that imply that By the way, with an older GNU sort version $ echo 04\n4 | sort --sort=version --stable
04
4
$ sort --version
sort (GNU coreutils) 8.32
... |
|
@timvisee That's right. I think this part of the source code is to blame: It seems to fall back on a default order if the specified sort compares equal and |
|
And my patch doesn't even work ;) |
|
Found the commit: coreutils/coreutils@d8047ae#diff-e0705db8518514c907d220d1879e28500a0fb802065a65d471ba9520235136ea Seems like it was intended behaviour to ensure a total order. Funnily enough, it seems to have been introduced based on a bug report by @miDeb which he filed while working on uutils sort, so we brought this upon ourselves 😄 |
|
ah ah, it would have been fun to share that in the talk at FOSDEM :) |
Fix misc/sort-version.sh
This is the demo that I did at fosdem
https://www.youtube.com/watch?v=90Q5N1qT7BQ