GNU bug report logs -
#6986
[PATCH] test: add check to determine whether files are on the same device
Previous Next
Full log
View this message in rfc822 format
Dieter Plaetinck wrote:
> In the test program, there is '-ef' which checks whether files
> are on the same device *and* have the same inode number.
> This change introduces '-ed' which is basically the same, minus the
> inode number checking
> ---
> src/test.c | 19 +++++++++++++++----
> 1 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/src/test.c b/src/test.c
Thank you for the patch.
However, can you make a case for adding this to test
rather than using an existing tool like stat?
For example, here's a tiny shell function:
same_dev()
{
local d1=$(stat --format=%d "$1") || return 1
local d2=$(stat --format=%d "$2") || return 1
test "$d1" = "$d2"
}
You could use it like this:
$ same_dev a b && echo same
same
$ same_dev a / && echo same || echo different devices
different devices
That it's so easy to accomplish the same thing with
existing tools makes it hard to justify adding the feature.
Besides, if you're really interested in getting this feature
into "test", you don't want to start with coreutils.
Its "test" program is used only rarely, since "test"
is always a shell built-in, these days.
Thus you'd want to request that your feature be added
to at least bash and zsh.
This bug report was last modified 14 years and 63 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.