Subject: bug#24154: bug in 'diff -B'

From: "Zieg, Mark (KSC-ESC-624)[VENCORE-ESC]" <[email-masked]>
Date: Thu, 4 Aug 2016 21:43:45 +0000

Hello,

When diffing an empty file against a one-byte file using -B (--ignore-blank-lines), diff incorrectly reports that the files are identical, even though they aren't even the same size.  The problem does not occur with files of 2 bytes or longer.  I tested this with diffutils 2.8, 3.2 and 3.3.

How to reproduce:

# create a one-byte file "foo"
deedwl262 [~/work/test] mzieg 09:17 PM $ echo -n x > foo

# create a zero-byte file "bar"
deedwl262 [~/work/test] mzieg 09:17 PM $ echo -n > bar

# confirm file sizes
deedwl262 [~/work/test] mzieg 09:18 PM $ ls -la
-rw-rw-r-- 1 mzieg unixusers 0 Aug  4 21:18 bar
-rw-rw-r-- 1 mzieg unixusers 1 Aug  4 21:17 foo

# verify "diff" works as expected
deedwl262 [~/work/test] mzieg 09:18 PM $ diff foo bar
1d0
< x
\ No newline at end of file

# verify "diff -w" works as expected
deedwl262 [~/work/test] mzieg 09:18 PM $ diff -w foo bar
1d0
< x
\ No newline at end of file

# verify "diff -b" works as expected
deedwl262 [~/work/test] mzieg 09:18 PM $ diff -b foo bar
1d0
< x
\ No newline at end of file

# HERE IS THE PROBLEM: diff -B does NOT work as expected
deedwl262 [~/work/test] mzieg 09:18 PM $ diff -B foo bar 

# change "foo" to a 2-byte file
deedwl262 [~/work/test] mzieg 09:18 PM $ echo  -n xy > foo

# now "diff -B" works as expected
deedwl262 [~/work/test] mzieg 09:19 PM $ diff -B foo bar 
1d0
< xy
\ No newline at end of file

Regards,

Mark Zieg
[email-masked]