bug-fileutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

diff -r is not flexible in handling symlinks


From: dworley
Subject: diff -r is not flexible in handling symlinks
Date: Mon, 22 Apr 2002 11:27:55 -0400

While attempting to use 'diff' to compare my Linux filesystem with a
replica of it, I discovered that diff -r always follows symlinks.
This was not useful, because my filesystem contained a symlink "SRC ->
..", which caused diff to get into an infinite loop.

I believe that this is a common problem, because many Unix system file
structures (and some software packages) contain links like "mh -> ."
and "SRC -> ..".  Gnu 'cp' has been designed to be flexible about
handling symlinks, and cp -r does not follow symlinks by default:

    File: fileutils.info,  Node: Top,  Next: Introduction,  Up: (dir)

    This manual documents version 4.0.36 of the GNU file utilities.

    [...]

       By default, `cp' follows symbolic links only when not copying
    recursively.  This default can be overridden with the
    `--no-dereference' (`-d'), `--dereference' (`-L'), and `-H' options.
    If more than one of these options is specified, the last one silently
    overrides the others.


    `-d'
    `--no-dereference'
         Copy symbolic links as symbolic links rather than copying the
         files that they point to, and preserve hard links between source
         files in the copies.

    `-L'
    `--dereference'
         Always follow symbolic links.

    `-H'
         If a command line argument specifies a symbolic link, then copy the
         file it points to rather than the symbolic link itself.  However,
         copy (preserving its nature) any symbolic link that is encountered
         via recursive traversal.

(I note that Sun's cp -r always follows symlinks, causing me headaches
while managing Sun systems -- I have to use "tar -c ... | tar -x ..."
instead of "cp -r".)

I believe that the utility of diff would be significantly enhanced if
its treatment of symlinks was made the same as cp's.

Dale



reply via email to

[Prev in Thread] Current Thread [Next in Thread]