Article View: gnu.utils.bug
Article #1404GNU diff 1.4 should report difference, not trouble, in dir vs file
From: Paul Eggert
Date: Sat, 05 Nov 1988 21:34
Date: Sat, 05 Nov 1988 21:34
59 lines
1905 bytes
1905 bytes
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
{
Technical Details
Message-ID:
<8811052134.AA16461@poi.sm.unisys.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!SM.UNISYS.COM!eggertShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!SM.UNISYS.COM!eggert From: eggert@SM.UNISYS.COM (Paul Eggert) Newsgroups: gnu.utils.bug Subject: GNU diff 1.4 should report difference, not trouble, in dir vs file Message-ID: <8811052134.AA16461@poi.sm.unisys.com> Date: 5 Nov 88 21:34:35 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 59