Tutorial Developer Reference 1 Introduction 2 Interface 3 Scanner 4 Parser 5 Analyser 6 Tangle 7 Weave 8 Shell 9 Commands 10 Glossary 11 References SEARCH

9.6 Diff

The `diff` command reads in two text files and appends a report to a log file containing a list of the differences between the two input files. If the log file does not already exist, an empty one is created first.

    Syntax  :
       diff = "diff" s filename s filename s
                       filename s ["ABORT"]
    Examples:
       diff result.tex answer.tex diff.log
       diff $Otest23.out $Atest23.out $Ldiff.log ABORT

The `diff` command performs a full line-based differences operation. It will identify different sections in a file, even if they are of differing length.

The implementation of the `diff` command is quite complicated. To be sure that it is at least getting its same/different proclamation right, the `diff` command performs a binary comparison as an extra check.

The following points describe the rules for determining the result status.

1. `diff` aborts with a severe error if the log file cannot be opened or created for appending.
2. An ordinary error is generated if either or both of the input files cannot be opened.
3. If, at the end of the run, the two input files have not been proven to be identical, and the `ABORT` keyword is present, `diff` returns severe status.
4. `diff` returns success status if none of the above conditions (or similar conditions) occur, even if the two files are different.

The `diff` command appends its differences report rather than merely writing it. This allows a regression test script to perform a series of regression tests and produce a report for the user.

The `diff` command was added to the shell after it had become apparent that the simpler `compare` command was not yielding enough information. Whereas early on, regression testing was treated mainly as a tool to ensure that FunnelWeb was being ported to other machines correctly, it began to place an increasing role during development in identifying the effects of changes made to the code. The `diff` command supports this application of regression testing by pinpointing the differences between nearly-identical text files.

Webmaster Copyright © Ross N. Williams 1992,1999. All rights reserved.