[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
diff -j for different handling of special files?
From: |
Mark Aitchison |
Subject: |
diff -j for different handling of special files? |
Date: |
Thu, 04 Mar 2010 12:11:44 +1300 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100225 Fedora/3.0.2-1.fc12 Lightning/1.0b1 Thunderbird/3.0.2 |
I notice that people have for a while wanted diff to handle special
files differently; I recently found I really wished diff would not just
report two links as if they are files with the same contents, e.g.
Files /usr/share/gnome/help/cheese/sv/figures/cheese-fullscreen.jpg
and /usr/share/gnome/help/cheese/C/figures/cheese-fullscreen.jpg are
identical
when one was a link to another, e.g.
lrwxrwxrwx. 1 root root 34 2009-11-10 08:20
/usr/share/gnome/help/cheese/sv/figures/cheese-effects.jpg ->
../../C/figures/cheese-effects.jpg
So I am thinking of writing and submitting a patch for diff to have the
option (it would maintain present behaviour without the link) of saying
something like:
File usr/share/gnome/help/cheese/sv/figures/cheese-fullscreen.jpg is
a symbolic-link to file
/usr/share/gnome/help/cheese/C/figures/cheese-fullscreen.jpg
or, in other circumstances:
File usr/share/gnome/help/cheese/sv/figures/cheese-fullscreen.jpg is
a regular-file [or device, directory, etc] symbolically linked from
/usr/share/gnome/help/cheese/C/figures/cheese-fullscreen.jpg
or
Files /usr/share/gnome/help/cheese/sv/figures/cheese-fullscreen.jpg
and /usr/share/gnome/help/cheese/C/figures/cheese-fullscreen.jpg are
links to the same file
This would mean a script that looks for duplicate files would not
accidentally delete the only copy of a regular file (no, I didn't do
that - but I did think of that happening with something like the was I
was searching for diff lines reporting files being identical), and it
may help in patch file generation in some situations, but I can imagine
that even more enhanced ways or reporting special files in differences
lists will be desired. It also keeps the first file the second field in
the output in each case, and the type of the first file in the first and
second cases is given after "is a" in the same format that script would
understand parsing something like:
File file5/file1 is a directory while file file1 is a regular file
in the present diff output.
Before starting, I'd like to ask if this is a reasonable thing to do.
I'm thinking of using the -j option (since it is one of the few letters
unused, and I'd like to keep -z for processing zip/etc archive
differences). The changes in documentation would be something like
(forgive the formatting):
-j
--just-files
Just compare contents of real files - if one or more files
to be compared is a link or any other "special" file just
report the types of the files (and if one is a link to the
other, or both a link to another file, report that). With
this option diff will never read either file if one is
special, and never report the files "are identical".
--just-files=filetype[filetype2...]
Restricts the type(s) of files diff will consider, and if
either is a special file diff will not read the contents but
just report differences in file type. Parameters may be one
or more of the following letters:
b block (buffered) special
c character (unbuffered) special
d directory
h hard link
p named pipe (FIFO)
f regular file
l symbolic link
s socket
D door (Solaris)
I also think it would be nice (but I'm not volunteering to do it at the
moment) to add options to diff to report any differences in the
ownership/permissions (and SELinux security content) etc. Perhaps using
-o. And I am quite keep to see a -z option to report differences in
(compressed) archives, reporting differences in files (even if they
appear in a different order) between two .zip files for example, or any
combination of .zip, .zoo, .tar, compressed tar, and real directory.
Thoughts?
Mark.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- diff -j for different handling of special files?,
Mark Aitchison <=