Article View: gnu.utils.bug
Article #97GNU DIFF 1.7 exit status wrong if only trailing newlines differ
From: Paul Eggert
Date: Thu, 06 Jul 1989 01:04
Date: Thu, 06 Jul 1989 01:04
30 lines
1306 bytes
1306 bytes
Suppose two files whose last lines are nonempty differ only in that one lacks
a trailing newline after its last line. Then GNU DIFF 1.7 exits with zero
status, meaning no differences. It should exit with status 1, because the
files differ. The following Bourne shell transcript illustrates the problem.
$ echo x >/tmp/x
$ tr -d '\012' </tmp/x >/tmp/y
$ if diff /tmp/x /tmp/y; then echo same; else echo different; fi
No newline at end of file /tmp/y
same
The following patch to diff_2_files() fixes the problem.
*** OLD/analyze.c Fri Feb 24 09:42:16 1989
--- analyze.c Wed Jul 5 09:08:58 1989
***************
*** 793,797 ****
free (e);
}
! return script ? 1 : 0;
}
--- 793,797 ----
free (e);
}
! return script || filevec[0].missing_newline != filevec[1].missing_newline;
}
-- Paul Eggert <eggert@twinsun.com>
Technical Details
Message-ID:
<8907060104.AA09931@twinsun.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!twinsun.com!eggertShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!twinsun.com!eggert From: eggert@twinsun.com (Paul Eggert) Newsgroups: gnu.utils.bug Subject: GNU DIFF 1.7 exit status wrong if only trailing newlines differ Message-ID: <8907060104.AA09931@twinsun.com> Date: 6 Jul 89 01:04:51 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 30