You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fmt: line-wrapping differs from gnu implementation in some situations #10095
When trying to come across edge cases in the non utf-8 fmt PR I came across that some outputs to fmt were not matching due to the line breaks being inserted in different places
Examples:
$ printf 'aa bb cc dd ee' | /usr/bin/fmt -w 8
GNU
aa
bb cc
dd ee
uutils
aa bb cc
dd ee
$ printf '漢 字 test 日 本 語' | /usr/bin/fmt -w 10
GNU
漢 字
test 日
本 語
uutils
漢 字 test
日 本 語
$ printf '漢字 test 日本語' | /usr/bin/fmt -w 15
GNU
漢字 test
日本語
uutils
$ printf '漢字 test 日本語' | uutils fmt -w 15
漢字 test 日本語
Where to fix:
src/uu/fmt/src/linebreak.rs is the file that has the logic
GNU fmt currently counts the \n as part of the count. That's confusing and inconsistent. I'll change that in the next couple of days. See GNU discussion
Hello, I'm a new contributor, is this issue up for grabs? I would love to take a look at this issue! Any general advice to get started would be appreciated
Hi @Victor140108, are you currently working on this? If you haven't started yet or are busy with other things, I would love to take a look and try to fix it. Let me know!
Quick retest against GNU fmt 9.11 (and current uutils main):
printf 'aa bb cc dd ee' | fmt -w 8 now matches on both sides (aa bb cc / dd ee) after GNU 9.10 stopped counting the trailing newline and after uutils #c138b386e.
The remaining mismatches are the CJK examples, where GNU still measures -w in UTF-8 bytes while uutils uses Unicode display columns.
So I won't reopen the approach from #12623 (global width - 1 for explicit -w). Planning a narrower fix: count word/indent width in bytes like current GNU, with regression tests for the issue's examples. Happy to adjust if maintainers prefer staying on display-width ahead of GNU's planned multibyte work.
Activity
ChrisDryden commentedon Jan 7, 2026
This might be the same issue as this: #5162 but its not limited to the goal option, it also applied to -w
pixelb commentedon Jan 7, 2026
GNU fmt currently counts the \n as part of the count. That's confusing and inconsistent. I'll change that in the next couple of days. See GNU discussion
elskow commentedon Jan 7, 2026
is this still up for grabs? I can take a take look at it.
Also, re: @pixelb's note. I'm assuming we want to match the current GNU output for now despite the upcoming changes?
ChrisDryden commentedon Jan 8, 2026
Yes I believe the goal is to target 1-1 compatibility with latest GNU
shreysang commentedon Mar 19, 2026
Hello, I'm a new contributor, is this issue up for grabs? I would love to take a look at this issue! Any general advice to get started would be appreciated
mattiabandini1 commentedon Mar 24, 2026
Hi @Victor140108, are you currently working on this? If you haven't started yet or are busy with other things, I would love to take a look and try to fix it. Let me know!
sankalpsthakur commentedon Jul 30, 2026
I'd like to take this on.
Quick retest against GNU fmt 9.11 (and current uutils
main):printf 'aa bb cc dd ee' | fmt -w 8now matches on both sides (aa bb cc/dd ee) after GNU 9.10 stopped counting the trailing newline and after uutils #c138b386e.-win UTF-8 bytes while uutils uses Unicode display columns.So I won't reopen the approach from #12623 (global
width - 1for explicit-w). Planning a narrower fix: count word/indent width in bytes like current GNU, with regression tests for the issue's examples. Happy to adjust if maintainers prefer staying on display-width ahead of GNU's planned multibyte work.fmt: measure -w in UTF-8 bytes to match GNU
fmt: measure -w in UTF-8 bytes to match GNU