Bug in diff
Ricardo Anido <[email protected]> Mon, 29 Jun 2015 16:00:48 +0100
| Newsgroups | gmane.comp.gnu.utils.bugs |
|---|---|
| Message-ID | <CAFY2ksSCbTpWdWJ=kBSH=efp_2cJXKZmz2O68rORSKct6f51bA@mail.gmail.com> |
If the last line of a file has a sole character and no '\n', using the flag
-B makes diff miss the difference between files. The difference is
correctly reported using flags -b or -w. Better explained by an example,
below. Notice that the last line of tmp2 has only the character 'X':
--------------------
ranido@ubuntu:~$ cat tmp1
a
b
c
ranido@ubuntu:~$ cat tmp2
a
b
c
Xranido@ubuntu:~$ od -cx tmp1
0000000 a \n b \n c \n
0a61 0a62 0a63
0000006
ranido@ubuntu:~$ od -cx tmp2
0000000 a \n b \n c \n X
0a61 0a62 0a63 0058
0000007
ranido@ubuntu:~$ diff -B tmp1 tmp2
ranido@ubuntu:~$ diff -b tmp1 tmp2
3a4
> X
\ No newline at end of file
ranido@ubuntu:~$
--------------------
Best regards, thanks for the amazing work on gnu!
---
Ricardo Anido
IC-UNICAMP
Av. Albert Einstein, 1251
13083-852 Campinas SP
Tel. (19) 3521 5863 Fax. (19) 3521 5847