Subject: Re: bug#7085: fmt (GNU coreutils) 6.10

From: Eric Blake <[email-masked]>
Date: Wed, 22 Sep 2010 15:08:01 -0600

On 09/22/2010 01:59 PM, Denis M. Wilson wrote:
> This program does not deal properly with CRLF terminators.
> Gratuitous CRs are left in joined lines; they should be
> removed. The user may want to keep the CRLF style or change
> to Unix (LF). There should be an option for this.

Thanks for the report.

POSIX is clear that CR is data and not a line terminator, so the 
existing behavior (in the absence of any new command-line option) is 
correct.

Now, we have a philosphy question - is it better to teach fmt a new 
command line option, and then have to wait for a new enough coreutils 
installation to propagate to various machines where you plan on using 
that extension, or is it better to use existing tools that are already 
portable according to POSIX and do the job now?  If you answered this 
question the same as me, then a solution that works now is favorable, so 
it becomes a question of massaging your files to get rid of the CR 
characters prior to using fmt on the file.  Something as simple as:

tr -d '\r' < file > file.out && mv file.out file

will do the trick.  Other common wrappers, like dos2unix, exist to make 
this sanitization process even easier.  So, I'm reluctant to add such a 
feature myself, and it will take some pretty strong arguments (such as 
existing practice in other fmt implementations) to convince me that a 
new option is worthwhile.

Meanwhile, you may want to consider upgrading to a newer coreutils; the 
latest stable version is 8.5, with a number of bug fixes in various tools.

-- 
Eric Blake   [email-masked]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org