On Sun, 2012-01-08 at 02:16 +0100, Bruno Haible wrote: > Andreas Gruenbacher wrote: > > I wonder if comparing symlinks (instead of what they point to) shouldn't > > become the default once diff supports it. At the very least, diff > > should warn when following symlinks though. > > I disagree. --dereference should stay the default, for two reasons: > > 1) Unix philosophy: By default, symlinks are followed. This is a > general principle. It starts with open() and fopen() and continues > through most command-line utilities. > > 2) What are the use-cases for "diff"? > - Compare files coming from two different users. > - Comparing the new state of a directory with a backup. > - Compating the new state of a partition with a backup. > > In the first two cases, --dereference is desired. In the third case, > --no-dereference is desired. > > The first two cases are the most frequent ones. > > In other words, while you personally may be working frequently at > the partition level, many users who put a symbolic link want it to be > followed automatically. > > See also the discussion at > <https://lists.gnu.org/archive/html/bug-gnu-utils/2011-10/msg00011.html> > <https://lists.gnu.org/archive/html/bug-gnu-utils/2011-10/msg00013.html>
I don't find these three use cases very instructive -- I either compare two files or two directory trees. In the two files case, I agree with what Paul Eggert says in the thread you refer to: > But the default behavior of "diff FILE1 FILE2" should remain > unchanged: it should follow symlinks, as many programs depend on this > behavior. Also, POSIX requires it. In the two directories case, I really don't see when following symlinks would be desirable. Here, diff is comparable to a tool like tar, for example -- in the tar case, I want to archive what's really there; in the diff case, I want to compare what's really there. Could you try to explain in more detail? In the behavior I have in mind, diff would default to following symlink command-line arguments but not to follow symlinks encountered while traversing a directory tree; this is what the -H mode is meant to do. Thanks, Andreas
