bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: On darwin, diff <(echo ab) <(echo cd) does nothing


From: Vincent Lefevre
Subject: Re: On darwin, diff <(echo ab) <(echo cd) does nothing
Date: Mon, 22 Aug 2005 01:57:31 +0200
User-agent: Mutt/1.5.10-vl-20050813i

On 2005-08-21 15:05:10 -0700, Paul Eggert wrote:
> Vincent Lefevre <address@hidden> writes:
> 
> > If there could be a Mac OS X workaround, like disabling the same_files
> > test when the files are in /dev/fd, then this would be fine.
> 
> Unfortunately that would not be reliable in general, since there
> might be a symbolic link to /dev/fd, or something else like that.

Yes, though this would be a workaround for the most common cases.

> This is clearly a bug in MacOS X.  POSIX says that if two file
> descriptions have the same st_dev and st_ino, then they must be the
> same file.

I know. I had a similar problem in the past with cp and a NAS, where
the backup file in the .snapshot had the same device and same inode
as the normal file (as the dates were different, this would not be a
problem for diff, which is more paranoid that cp, which just checks
the device and the inode values). BTW, the comment in system.h
mentions this bug.

> Can you please file a bug report with the MacOS X folks?

I've just done it.

> In the meantime, how about if diff looks at the st_mtime too
> (including the nanoseconds component)?

It already does this. From system.h:

#ifndef same_file_attributes
# define same_file_attributes(s, t) \
   ((s)->st_mode == (t)->st_mode \
    && (s)->st_nlink == (t)->st_nlink \
    && (s)->st_uid == (t)->st_uid \
    && (s)->st_gid == (t)->st_gid \
    && (s)->st_size == (t)->st_size \
    && (s)->st_mtime == (t)->st_mtime \
    && (s)->st_ctime == (t)->st_ctime)
#endif

Instead of checking the file name (vs /dev/fd/*), one can say that
if a file is a fifo, then the files are different. Even if two fifos
were the same file, I think it is a bug not to read them, since this
is an optimisation that has a side effect.

-- 
Vincent Lefèvre <address@hidden> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA




reply via email to

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