Subject: Re: bug#18291: Unix Sort Bug Report

From: Pádraig Brady <[email-masked]>
Date: Mon, 18 Aug 2014 16:57:36 +0100

On 08/18/2014 09:55 AM, NTENTOS STAVROS wrote:
> 
> Hello developers,
> 
> Recently, using the sort utility I run into an omission. While I cannot disclose the file in question, I will try to explain the issue:
> On a Windows-created file (line ending: \r\n) I tried to perform a sorting, which happened to sort the last entry somewhere above. The last line did not have a line ending of any kind, and sort created a Unix-like ending (\r), which afterwards creates a parsing problem with the file.

Well a \n is inserted actually, not \r, but yes that is a problem on windows.
This demonstrates the behavior:

  $ printf '2\r\n1' | sort | od -Ax -tx1z -v
  000000 31 0a 32 0d 0a                                   >1.2..<

The \n is inserted so as to delimit the reordered item appropriately,
which is set here:

http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/sort.c;h=c2493192;hb=HEAD#l178

It seems that this should be set to '\r\n' on cygwin builds,
(wither other adjustments to handle multiple chars).

thanks,
Pádraig.