[gnu.utils.bug] GNU diff 1.4 should report difference, not trouble, in dir vs file

eggert@SM.UNISYS.COM (Paul Eggert) (11/06/88)

Consider the following scenario, where GNU diff 1.4 (SunOS 4.0 + Sun-3/60)
compares a file to a directory.

	% mkdir a b a/x
	% touch b/x

	% diff a b
	a/x is a directory but b/x is not
	% echo status = $?
	status = 2

	% diff a b/x
	diff: a/x is a directory but b/x is not
	% echo status = $?
	status = 2

The exit statuses should both be 1, not 2: 1 means "differences found" and 2
means "trouble".  There's no standard here: for example, SunOS 4.0 diff yields
exit statuses 1 and 2, respectively, while Vax 4.3BSD diff yields 2 and 1.  But
I think 2 should be reserved for real errors like "permission denied", and 1
should be used when files merely differ in type (i.e. file vs directory).
Here is a fix.

*** diff1.4/diff.c	Sat Nov  5 13:31:24 1988
--- diffnew/diff.c	Sat Nov  5 13:20:42 1988
***************
*** 487,493 ****
  	    {
  	      error ("%s is a directory but %s is not",
  		     inf[dir_arg].name, inf[fnm_arg].name);
! 	      val = 2;
  	    }
  	  else
  	    val = diff_2_files (inf, depth);
--- 487,493 ----
  	    {
  	      error ("%s is a directory but %s is not",
  		     inf[dir_arg].name, inf[fnm_arg].name);
! 	      val = 1;
  	    }
  	  else
  	    val = diff_2_files (inf, depth);
***************
*** 517,523 ****
  		     inf[1].name, inf[0].name);
  	}
  
!       val = 2;
      }
    else
      {
--- 517,523 ----
  		     inf[1].name, inf[0].name);
  	}
  
!       val = 1;
      }
    else
      {