[Top][All Lists]

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

Re: cmp doesn't accept directories

From: Paul Eggert
Subject: Re: cmp doesn't accept directories
Date: Fri, 26 May 2006 16:49:26 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Eric Blake <address@hidden> writes:

> It states that results are undefined if the two input files are both
> stdin, the same FIFO, block, or character special file

I suspect this is so that 'cmp' can optimize the special case of 'cmp
FOO FOO' and not bother to read from FOO, without worrying about
whether FOO is a special file.  GNU cmp has this optimization.

> but does not have any restrictions about directories.  But how is
> cmp supposed to tell you which byte differs on a directory?

It uses read().  It might work; POSIX allows it to work.  If it
doesn't succeed, cmp reports an error.

We could add an option to 'cmp' to get the behavior that Dan Jacobson
wants, but it shouldn't be the default behavior since it's an
incompatible change.

reply via email to

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