CMP -- Compare Text or Binary Files
Revision History

program and documentation by Stan Brown, Oak Road Systems
release 5.13, revised 17 Dec 2001
Copyright © 2001 by Stan Brown, Oak Road Systems

CMP will compare text or binary files (or groups of files) and report any differences. Output is suitable for piping, or processing by other programs. A value returned in ERRORLEVEL lets batch files take action based on whether files are the same or differ.

This document is the complete revision history, starting with the most recent changes. For user instructions, please see the separate user guide.


What's New in CMP 5


CMP 5.13, 17 Dec 2001

This is a minor release. By user request, "file not found" messages /C option) are now written to both standard output and standard error, if you redirected standard output to a report file. Also by user request, when you append debug output to an existing file, a prominent header separates new output from previous output. Other minor improvments to debug output include a clearer list of filespec arguments, for help in diagnosing possible user errors on the command line.

CMP 5.12, 2 July 2001

This is a minor release. It adds one feature: when comparing multiple files, CMP now tells you at the end how many pairs were the same, how many pairs were different, and how many sought files were missing.

One line of the help message was 82 characters long; now it isn't.

CMP 5.11, 5 June 2001

This is a very minor release, for one new feature: CMP now tells you not only how many blocks of lines were different between the two files, but also how many actual lines were different.

CMP 5.1, 8 April 2001

new feature:

bugs fixed:

CMP 5.0, 4 March 2001

CMP 5.0 was a complete rewrite of the program from scratch. The program is about 40 pages of code, compared to about 14 pages for the previous release, CMP 4.3! The executables are still comfortably small, under 90 KB for CMP32 and 60 KB for CMP16.

If you used CMP 4.3 or earlier, please see the Transitional Note below.

The new program can handle binary files, can search subdirectories, displays results in your choice of formats, and makes better use of available memory; details are listed below. The user guide has been very greatly revised and expanded, and this revision history has become a separate document. A demo has been added to display some of CMP's features.

New options:

Old options enhanced:

Other enhancements:


Transitional Note, CMP 4 -> CMP 5


If you are upgrading from CMP 4.3 or earlier, please note that certain options have changed their meanings. This section points them out and tells you how to retain the old behavior if you want to.

If you use the ORS_CMP environment variable to store options, make sure to check it and see whether you need to make changes.

Please see What's New in CMP 5 for a number of new options and other enhancements.

Transforming Inputs: /B, /E, /T

The /B option and the /E option now default to the opposite of their old settings. Formerly, if you did not specify any options, CMP would do some massaging of the file lines before comparing. Now, by default CMP compares files character for character.

If you want the old behavior, you can get it easily. For individual runs of CMP, specify the /BE options on the command line. If you simply want to restore the old defaults, you can use the environment variable. Put this command in your AUTOEXEC.BAT file:

        set ORS_CMP=/BE

In this case, you may want to consider the new /M option as well.

The /T option has been withdrawn. It allowed you to expand tabs to an equivalent run of spaces, but this was redundant with the /B option.

Comparison Resync: /L

CMP 4.3 and earlier would consider that files were resynchronized after a difference block as soon as it found a line in file 1 that matched a line in file 2. If you edited every other line of a paragraph or block of code, you would get a lot of little difference blocks.

To avoid this, CMP now requires two consecutive identical lines before it considers a difference block to have ended. Though that will usually give a more usable report that the old default, it's not be the best choice for every comparison. You can now use the /L option to increase or decrease that value. This flexibility should let you get much better difference reports for many sets of files.

If you want to restore the old behavior as the default, you can use an environment variable. Put this command in your AUTOEXEC.BAT file:

        set ORS_CMP=/L,1

Note that comma after the letter L.

Suppressing Messages: /Q, /QQ

The /Q option has changed from a pure toggle to a numeric, /Q0 through /Q3. You will still get the old behavior if you type /Q or /QQ.

Because you can combine options, one particular combination has changed its meaning. /Q1 or /Q0 used to mean the /Q option followed by the /1 option or the /0 option; now it means the /Q option setting quietness level 1 or 0. To specify separate options, simply use a slash or hyphen between them, or specify them in the other order: /Q/1 or /1Q.

Displaying Massaged Lines: /M

Before release 5.0, CMP would transform ("massage") the input lines to collapse runs of blanks. To conserve computer memory, CMP would store and display only the massaged lines. Then when CMP reported differences, it would display the massaged lines, which would be similar to the lines in the files but not necessarily identical.

Beginning with release 5.0, CMP saves both the massaged and the original lines, and displays the original lines. If you want to display the massaged lines, use the /M option. If you want that behavior to be the default, you can use the environment variable. Put this command in your AUTOEXEC.BAT file:

        set ORS_CMP=/M

This is less of an issue than it was before CMP 5.0. In earlier releases of CMP, lines were massaged unless you set options to prevent it. Now, lines are not massaged unless you set /B option or the /I option. So if you set no options at all, CMP 5.0 will display difference lines exactly as they are in the files, which is probably what you'd expect.


History of Older Versions


This section is of only historical interest, since the program was completely rewritten in February 2001. But some users have said they find a complete revision history interesting, so here it is.

CMP 4.9, 8 Feb 2001

This was a beta release version of 5.0. Between this and the final release, a number of improvements were made, including some new features, and a few bugs were fixed. Full details were in the CMPBETA5.HTM file distributed with release 5.0.

CMP 4.3, 22 May 2000

Added the /Z option; updated the logo message to use the URL for Oak Road Systems; expanded the help message; suggested "cmp /?|more" when the user types cmp with no files.

CMP 4.3a, 24 Aug 2000, updated the user guide but did not change the program. It clarified the ERRORLEVEL returns with the /1 and /0 options when multiple files are compared. It also spelled out the limitation that CMP couldn't be used for binary files; that capability was added in CMP 5.0.

CMP 4.2, 31 Oct 1999

Added the /F option, the /N option, and the /QQ option; sent the help message to stdout instead of stderr as previously; reorganized the user guide, adding many hyperlinks and a few small clarifications.

CMP 4.1, 9 Jan 1999

Added the /I and /D options. Split the confusing three-valued /Bn option into separate /B and /T toggle-type options. (The /T option was dropped from release 5.0.) Changed the CMP32 default to /L100. Improved diagnostics for a bad option in the environment variable. Converted documentation to HTML from Word for Windows.

Two minor releases involved no changes to the program or user guide. Version 4.1a, 20 Feb 1999, updated contact information when Oak Road Systems changed Internet providers. Version 4.1b, 4 Aug 1999, updated contact information when we changed physical addresses; it also simplified the registration options and added site license pricing.

CMP 4.0, June 1998

Allowed multiple file specs before a directory name, not just one file spec with wild cards. Supported long filenames in the new 32-bit version.

CMP 4.0 was packaged on 18 Nov 1998 for the first shareware release.

CMP 3.4, Oct 1997

Added the /0 and /1 options; systematized all return values. Stopped requiring the trailing backslash on a directory argument. Instead of "effectively identical", reported a more specific phrase when the files are not significantly different based on the /B option and the /E option.

CMP 3.3, July 1997

Compressed sequences of spaces and tabs to a single space; added the /B option to control that feature and tab expansion. Added the /Q option. Made the format of command-line options more flexible, and scanned the ORS_CMP environment variable for options.

CMP 3.0, July 1994

Allocated string arrays far, allowing larger combined values of /L and /W.

CMP 2.4, Nov 1989

Defaulted to /L20 (previously /L10).

CMP 2.1, March 1985

Expanded tabs in input lines to the appropriate number of spaces.

CMP 1.1, Oct 1984

Allowed wild cards in the first file argument.

CMP 1.0, Aug 1984

Initial release (private releases, to clients only, until 4.0)