Subject: Re: CVS commit: src/usr.bin/find
To: Christos Zoulas <christos@zoulas.com>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: source-changes
Date: 10/22/2005 09:15:28
On Fri, Oct 21, 2005 at 10:51:49PM -0400, Christos Zoulas wrote:
> On Oct 22,  3:51am, zafer@gmx.org ("Zafer Aydogan") wrote:
> -- Subject: Re: CVS commit: src/usr.bin/find
> 
> | I were referring to my example in the PR.
> | 
> | $ find /usr/share/ -name Berlin
> | /usr/share//zoneinfo/Europe/Berlin
> | $ uname -a
> | NetBSD  3.99.10 NetBSD 3.99.10 (GENERIC) #0: Mon Oct 17 19:49:55 CEST 2005 
> | zafer@moe.aydogan.net:/usr/obj/sys/arch/i386/compile/GENERIC i386
> | $
> | Please notice the double slash behind share.
> | Why does /usr/share/ have a trailing slash ? 
> | Because it is a directory and /bin/ksh completes it with Tab. 
> | 
> | But, the same on FreeBSD shows:
> | 
> | $ find /usr/share/ -name Berlin
> | /usr/share/zoneinfo/Europe/Berlin
> | $ uname -a
> | FreeBSD vim.aydogan.net 6.0-RC1 FreeBSD 6.0-RC1 #0: Sun Oct  9 20:32:57 UTC
> | 2005     root@x64.samsco.home:/usr/obj/usr/src/sys/GENERIC  i386
> | $
> | 
> | and Linux:
> | 
> | $ find /usr/share/ -name Berlin
> | /usr/share/zoneinfo/Europe/Berlin
> | /usr/share/zoneinfo/posix/Europe/Berlin
> | /usr/share/zoneinfo/right/Europe/Berlin
> | $ uname -a
> | Linux eva 2.6.6-040601 #1 SMP Tue Jun 1 18:32:50 CEST 2004 i686 i686 i386
> | GNU/Linux
> | $
> | 
> | etc.etc. with Solaris, AIX, IRIX, HP-UX.
> | Please notice one slash after share in the results and trailing slash in the
> | find argument.
> | If I have one trailing slash, why does NetBSD show two ?
> | And if I use two, it shows three. 
> | 
> | 
> | > 
> | > I don't see that:
> | > 
> | > # uname -a
> | > Linux xxx 2.6.11-ts6 #10 SMP Wed Aug 17 20:22:03 GMT 2005 i686 athlon i
> | 
> | What really bugs me is, that this is a completely normal behaviour (in my
> | opinion). And I cannot remember any canonical Problems on Linux neither
> | FreeBSD since years. 
> | So I was surprised to see this on NetBSD. 
> 
> That particular one is easy to fix; they appear to do something like:
> 
> if (path ends with a slash)
> 	printf("%s%s\n", path, rest);
> else
> 	printf("%s/%s\n", path, rest);
> 
> But that is a special case, it is not path normalization which they don't do.
> They are not really trimming trailing slashes or anything. We can do the same
> too.

In this example, if /usr/share is a symlink pointing to some other directory,
find /usr/share/ will follow it, while find /usr/share will not:
baladeur# cd /tmp/
baladeur# ln -s /usr/share .
baladeur# find /tmp/share -name Berlin
baladeur# find /tmp/share/ -name Berlin
/tmp/share//zoneinfo/Europe/Berlin

Stripping the trailing slash in find may cause a change in behavior in this
case, but I don't know if it's a real problem or not (find /tmp/share/. would
still work ok).

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 26 ans d'experience feront toujours la difference
--