bug-diffutils
[Top][All Lists]
Advanced

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

[bug-diffutils] bug#21942: Files with incorrect file sizes


From: Stephan Müller
Subject: [bug-diffutils] bug#21942: Files with incorrect file sizes
Date: Tue, 17 Nov 2015 12:44:08 +0100

Hi there,

recently I had to debug weird problem. Finally I figured it out.

Virtual file systems like /sys or /proc usually don't care about file
sizes. All files have a size of 0. This leads to difficulties as diff
sometimes looks for file sizes.

Say you do:

> $ cp /proc/cmdline my_cmdline
> $ diff /proc/cmdline my_cmdline ; echo $?
> 0      // ok, files don't differ
> $ diff --brief /proc/cmdline my_cmdline
> Files /proc/cmdline and mycmdline differ  

The --brief option triggers a binary compare, as we aren't interested
in the actual differences this makes sense. As a first step, file sizes
are compared (0 vs ~150) and the files are reported as different.

I am not sure how to fix this. I.e. are the files different or not? What
is the correct behavior. In any case --brief should have no influence on
the overall result! I see the following options (I prefer the 2nd):

1: Don't use file sizes in comparing. This is rather expensive but
would certainly fix it.

2: add a --use-file-sizes flag which enables decisions
based on file sizes. Without this flag, always look into the files.
And --brief should report, if the files differ because of their data or
size. That is 

> $ diff /proc/cmdline my_cmdline ; echo $?
> 0      // ok, files don't differ  

> $ diff --brief /proc/cmdline my_cmdline ; echo $0
> 0  

> $ diff --brief --use-file-sizes /proc/cmdline my_cmdline
> Files /proc/cmdline and mycmdline differ in file size  

3: Leave it at it is and add a warning in the man page. However that
would be very inconvenient.


   best, stephan





reply via email to

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