GNU bug report logs - #24154
bug in 'diff -B'

Previous Next

Package: diffutils;

Reported by: "Zieg, Mark (KSC-ESC-624)[VENCORE-ESC]" <mark.zieg <at> nasa.gov>

Date: Thu, 4 Aug 2016 22:23:02 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Zieg, Mark (KSC-ESC-624)[VENCORE-ESC]" <mark.zieg <at> nasa.gov>
To: "bug-diffutils <at> gnu.org" <bug-diffutils <at> gnu.org>
Subject: bug in 'diff -B'
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
mark <at> zieg.com




This bug report was last modified 9 years and 5 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.