What are the error exit values for diff?

sid_com picture sid_com · Aug 7, 2011 · Viewed 56.9k times · Source

On the diff man-page I've found these exit values:

    0     No differences were found. 
    1     Differences were found.
   >1     An error occurred.

Are there different exit values above 1 for different errors?

Answer

Frédéric Hamidi picture Frédéric Hamidi · Aug 7, 2011

It depends on your diff command. Mine (GNU diffutils 3.0) says:

An exit status of 0 means no differences were found, 1 means some differences were found, and 2 means trouble. Normally, differing binary files count as trouble, but this can be altered by using the -a or --text option, or the -q or --brief option.