Subject: diff -Z hangs [was: [bug-diffutils] bug#15459: bug#15459: bug#15459: bug#15459:]

From: Eric Blake <[email-masked]>
Date: Wed, 25 Sep 2013 10:20:20 -0600

On 09/25/2013 10:05 AM, Eric Blake wrote:
> On 09/25/2013 09:52 AM, leila karami wrote:
>> Dear Eric
>>
>> I obtained old.gro file from linux, then I changed and saved it in windows
>> (new.gro). I want to use new.gro file in linux again.
>>
>> I attached files in free compression format (such as gzip).
>>
>> I want to do some works to obtained new.gro file exactly similar to style
>> and format of the old.gro to use new.gro in linux.
>> Please tell me how to do this work exactly?
> 
> If line endings are all that differs, use 'diff -Z' to ignore the
> trailing space differences, or download the 'dos2unix' utility and
> reconvert your file back into desired line endings before doing the diff.

Hmm, you may have found a real bug after all:

$ diff --version | head -n1
diff (GNU diffutils) 3.3
$ diff -Z <(printf 'a\nb\n') <(printf 'a\nb\n'); echo $?
0
$ timeout 10s diff -Z <(printf 'a\r\nb\n') <(printf 'a\nb\r\n'); echo $?
124

Why is 'diff -Z' going into an infinite loop and timing out after ten
seconds, instead of ignoring differences caused by mixed-mode carriage
returns?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org