bug#79497: fmt breaks lines when it does not need to

Bruno Haible via GNU coreutils Bug Reports <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Organization GNU
Message-ID <8183373.3yuU7cT3dn@nimes>
Hi Pádraig,

Thanks for answering. So, we have the multibyte problem and the
newline-included problem.

Pádraig Brady wrote:
> The code seems to follow the man page and includes the \n in the char count.
> Note fold -w does not count the newline which is what I'd expect.

I ran this test case with various 'fmt' implementations:

$ echo 'Hello world' | fmt -w 11
Hello
world
$ echo 'Hello world' | fmt -w 12
Hello world

The minimum -w option that produces a single line:

GNU              12
macOS, FreeBSD   11
NetBSD           11   (-g 10 -w 11)
OpenBSD          11
AIX, Solaris     12

So, the BSD implementations don't count the newline.

Bruno
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.