This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to compare two text files? Using sed, cmp, diff, tr?

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                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]