This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How to compare two text files? Using sed, cmp, diff, tr?
- From: Joerg Wunsch <j at uriah dot heep dot sax dot de>
- To: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- Cc: Georg-Johann Lay <avr at gjlay dot de>, gcc at gcc dot gnu dot org
- Date: Sat, 26 May 2012 17:42:00 +0200
- Subject: Re: How to compare two text files? Using sed, cmp, diff, tr?
- References: <4FC0AA16.2040709@gjlay.de> <CAH6eHdROkZSw3dMiS8Jp09ymzxdpSRY5rS7GR8UY=YJRmkEvJA@mail.gmail.com>
- Reply-to: Joerg Wunsch <joerg_wunsch at uriah dot heep dot sax dot de>
As Jonathan Wakely wrote:
> POSIX diff with the -b option should report the files as equal, I
> don't know if that's portable enough to rely on though.
I think it is. The Single Unix Specification requires the -b option
("Cause any amount of white space at the end of a line to be treated
as a single <newline>"), and the exit status 0 for "no differences
found", 1 for "differences found", and > 1 for "an error occurred" are
also standardized. I don't know of any (even historic) diff that
doesn't provide -b.
There's no option to suppress printing the differences to stdout
though, and redirecting the output to a null device is likely not
portable. I don't know whether this situation already applies to
other GCC Makefiles, but perhaps the most portable way for this is to
redirect stdout to a dummy file, and delete that file afterwards.
--
cheers, J"org .-.-. --... ...-- -.. . DL8DTL
http://www.sax.de/~joerg/ NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)