Description |
The EXIT STATUS section for diff includes:1 Differences were found.
>1 An error occurred. If differences are found but an error occurs when the differences are being written to standard output, then both of these descriptions are true, and the standard does not specify a precedence between them, which means that at first sight conforming implementations can exit with status 1 or >1.
When the rules from 1.4 Utility Description Defaults are brought into play, it is apparent that the exit status has to be >1, but it would be better if it was easily seen from just the diff EXIT STATUS section rather than having to follow this chain of reasoning:1.4 under CONSEQUENCES OF ERRORS says "A diagnostic message shall be written to standard error whenever an error condition occurs."
diff STDERR says "The standard error shall be used only for diagnostic messages."
1.4 under STDERR says "When this section is listed as ``The standard error shall be used only for diagnostic messages.'', it means that, unless otherwise stated, the diagnostic messages shall be sent to the standard error only when the exit status indicates that an error occurred and the utility is used as described by this volume of POSIX.1-2017.
Therefore if an error occurs when writing the differences a diagnostic message has to be written, and because a diagnostic message was written the exit status has to be one that indicates an error occurred (if the utility is used as described...).
|