Thread View: gnu.utils.bug
1 messages
1 total messages
Started by Paul Eggert
Sat, 05 Nov 1988 21:34
GNU diff 1.4 should report difference, not trouble, in dir vs file
Author: 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
{
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads