[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
diffutils proposal: cmp FILE DIR/ ==> cmp FILE DIR/$(basename FILE)
From: |
Chris Chittleborough |
Subject: |
diffutils proposal: cmp FILE DIR/ ==> cmp FILE DIR/$(basename FILE) |
Date: |
Tue, 03 Aug 2004 22:33:50 +0930 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113 |
I think cmp would be more expert-friendly if it acted like diff when
asked to compare a file to a directory -- that is, it should look for a
file in the specified directory with the same basename as the specified
file.
More formally, using bash for notation, I want
cmp FILE DIR/ ==> cmp FILE DIR/$(basename FILE)
and cmp DIR/ FILE ==> cmp DIR/$(basename FILE) FILE
(The Single Unix Specification allows read(2) from a directory to fail
with EISDIR. GNU/Linux does this. On such systems, cmp FILE DIR
currently fails with "cmp: DIR: Is a directory".)
It is easy to patch cmp.c to do this in either of two ways:
(1) If one filename arg ends with '/' and the other does not (and
is not "-"), append the basename of the latter to the former.
(2) Once we have opened and fstat()ed the two files, see if one is
a directory and the other a file with a non-"-" name; if so,
close the directory and try to open the appropriate file in
that directory.
The reason I'm posting this is to ask:
* Which of these two approaches do people think is better?
* Would the diffutils maintainers like a patch that makes this
change (and updates the documentation)?
(BTW, my next project is to add --from-related-file=PATTERN to diff.)
Does anyone have any comments about this
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- diffutils proposal: cmp FILE DIR/ ==> cmp FILE DIR/$(basename FILE),
Chris Chittleborough <=