ERROR(1) — Unix Programmer’s Manual
NAME
error − analyze and disperse compiler error messages
SYNOPSIS
error [ options ] [ file ]
DESCRIPTION
Error analyzes the diagnostic error messages produced by a number of compilers and language processors, and optionally disperses them to the source file and line where the errors occurred. The user need not write down errors on paper, since this command permits error messages and source code to be viewed simultaneously, without manipulation of multiple windows in a screen editor.
The error command analyzes the error messages, either from the specified file or from the standard input; it identifies the language processor which produced each error message, and the source file and line number to which the error message refers. It also determines whether or not the error message should be ignored. Error inserts the error message into the source file as a comment, placing it on the line before the error. It may slightly modify the message. It sends to the standard output those messages which it cannot categorize by language processor or by content, without inserting them into any file. Error touches source files only after all input has been read.
Error is intended to have its standard input connected via a pipe to the error message source. Some language processors put error messages in their standard error file; others put their messages on the standard output. Hence, both error sources should be piped together into error. For example, when using the csh syntax
make −s lint |& error −q −v
error will analyze all the error messages produced by the programs which make runs when making lint.
Error can handle the error messages produced by the commands make, cc, cpp, ccom, as, ld, lint, pi, pc and f77. It recognizes a standard format for error messages produced by the language processors, thus it is sensitive to changes in these formats. For all languages except Pascal, the length of error messages is restricted to a single line. Some error messages refer to more than one line in more than one files; error will duplicate the error message and insert it at all of the places referenced.
There are six types of error message; error handles each in different way.
Synchronize:
Some language processors produce short errors describing which file is being processed. Error uses these to determine the filename for languages that do not include the filename in each error message. These synchronization messages are consumed entirely by error.
Discard: Error messages from lint that refer to one of the two lint libraries, /usr/lib/llib-lc and /usr/lib/llib-port are discarded, to prevent accidently touching these libraries. Again, these error messages are consumed entirely by error.
Nullify: Error messages from lint can be nullified if they refer to a specific function which is known to generate diagnostics that are not of interest. Nullified error messages are not inserted into the source file, but are written to the standard output. The names of functions to ignore are taken from either the file named “.errorrc” in the user’s home directory, or from the file named by the −I option. If the file does not exist, no error messages are nullified. If the file does exist, there must be one function name per line.
Not file specific:
Error messages which cannot be analyzed are grouped together and written to the standard output before any files are touched. They will not be inserted into any source file.
File specific:
Error messages that refer to a specific file, but to no specific line, are written to the standard output when that file is touched.
True errors:
Error messages that can be analyzed are candidates for insertion into the file to which they refer.
Only true error messages may be inserted into the file to which they refer. Other error messages are consumed entirely by error or are written to the standard output. Error inserts the messages into the source file on the line preceding that which the language processor found to be in error. Each error message is transformed into a one-line comment for the language, and is internally flagged with the string ### at the beginning of the error, and %%% at the end of the error. This makes it easier to search for patterns using an editor, and to remove the messages. In addition, each error message contains the source line number for the line to which the message refers.
A reasonably well formatted source program can be recompiled without removing the error messages; the messages themselves need not cause future errors. For poorly formatted source programs in free format languages such as C or Pascal, it is possible to insert a comment into another comment. This can wreak havoc with a future compilation. To avoid such problems, programs with comments and source on the same line should be formatted so that language statements appear before comments.
OPTIONS
−I ignorefile
Retrieves the list of files to be ignored from ignorefile.
−n Does not touch any files; all error messages are sent to the standard output.
−q The user is queried before each source file is touched. A y or n reply is necessary to continue. Absence of the −q option implies that all referenced files (except those referring to discarded error messages) are to be touched.
−s Prints out statistics regarding the error categorization.
−t Takes the following argument as a suffix list. Only files with listed suffixes are touched. The list is dot-separated; ∗ wildcards work. Thus the suffix list:
.c.y.foo∗.h
allows error to touch files ending with .c, .y, .foo∗ and .h.
−v Sets up vi, the visual editor, to edit all files that have been touched. It is positioned in the first touched file at the first error. If vi cannot be found, it tries ex or ed from standard locations. When using this option, standard output should be redirected to a file. This will ensure that the user has time to read all error messages, without earlier ones being cleared from the screen as later ones are displayed.
Error catches interrupt and terminate signals; if in the insertion phase, it will terminate its operation in an orderly manner.
FILES
~/.errorrcfunction names to ignore for lint error messages
/dev/ttyuser’s teletype
BUGS
Opens the teletype directly to do user querying. Source files with links make a new copy of the file with only one link to it. Changing a language processor’s format of error messages may destroy the ability of error to understand the error message. Since it is purely mechanical, error will not filter out subsequent errors caused by “floodgating” initiated by one syntactically trivial error. Humans are still much better at discarding these related errors. This is not too serious a drawback, since the inserts made by error are so distinctive that they can be eradicated by a single global editor command.
Pascal error messages belong after the lines affected (error puts them before). The alignment of the | marking the point of error is also disturbed by error. Error was designed for work on CRTs at reasonably high speed. It is less pleasant on slow speed terminals, and has never been used on hardcopy terminals.
4th Berkeley Distribution — 1 August 1985