Hi Karl,

Karl Berry <[email protected]> writes:

> I ran
>   echo in | fmt -w 9999 >/tmp/out
> and was surprised to get the error:
>   fmt: invalid width: '9999': Numerical result out of range
>
> Why is it fmt's business to decide what value is acceptable?
> Does POSIX require this arbitrary limit?
> I don't see the limit documented in coreutils.texi or fmt --help.

The 'fmt' program isn't a part of POSIX.

> This is with fmt (GNU coreutils) 8.32. Sorry if it is fixed in a newer
> release.
>
> Rationale: I was using fmt as a quick way to concatenate a bunch of
> short lines into one. I am aware there are many other ways to do it. -k

It still exists and is a longstanding limitation, see a bug report for
the same issue from 2011 [1].

I agree it would be nice to fix, along with the lack of multi-byte
character support. But one would have to be careful to be compatible
with the original implementation. I have not read the algorithm cited in
the info page by Donald E. Knuth and Michael F. Plass, and the 'fmt'
souce code is not very enjoyable to read. Hence, I have not gotten to
it yet.

Collin

[1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=9680



Reply via email to