Subject: Re: Pathnames with trailing /
To: NetBSD Kernel Technical Discussion List <tech-kern@NetBSD.org>
From: Greywolf <greywolf@starwolf.com>
List: tech-kern
Date: 09/08/2003 12:41:26
Thus spake Greg A. Woods ("GAW> ") sometime Today...

GAW> Actually with the traditional and proper UNIX System way of doing things
GAW> the slash character in a pathname is a separator token only and it
GAW> doesn't matter how many there are at any place in a pathname, and even
GAW> putting one or more at the end of the pathname doesn't imply anything
GAW> special.  This is well documented right back into the Sixth Edition
GAW> source code, as per the Lions' commentary on that code.

We aren't living in a Sixth Edition world anymore...

GAW> The original Unix view of pathname separators is much more elegant.
GAW> It's also much more intuitive, once you understand the true meaning of
GAW> the slash character.  After all, if one really wanted to specify an
GAW> existing pathname as a directory then one would be quite explicit about
GAW> it and properly append the "/." and not depend on the non-portable
GAW> behaviour of some particular kernel to do this for them.

I think that what they did actually makes sense.

GAW> Note also that all the whining about problems of trailing slashes

"whining" == "offends your sensibilities".  Call it as it is...

GAW> introduced by shells that do filename completion in a certain way is
GAW> pure bunk.  These problems only occur in *BSD systems because of the
GAW> poor decision to treat trailing slashes as something more than just
GAW> extraneous separator tokens.  On traditional systems those trailing

What's a "traditional system" anymore, Greg?  There is "traditional
behaviour" (which, according to POSIX, which as we know EVERYONE follows
(not!), is incorrect in this case)...

GAW> slashes are simply ignored by the kernel and thus such problems cannot
GAW> ever occur.  Trailing slashes should not imply that a pathname is
GAW> supposed to be directory.  They should be stripped and ignored as any
GAW> trailing whitespace would be by any shell tokenizer, or ignored as
GAW> additional trailing NUL characters are ignored by both applications and
GAW> the kernel.  The worst possible thing to do is to pretend that the

Hm.  Play with 'awk -F/ "{print NF}"' for a while.  See what happens
when you feed it /foo/bar/and/grill and /foo/bar/and/somethingelse/.

GAW> filename "." has been appended to the pathname and yet that's exactly
GAW> the choice that was made for *BSD.

Why is this the worst possible thing to do?  Why does it not make sense?

To look at it visually, it makes *perfect* sense.

GAW> I don't know what we're supposed to do now that POSIX has embedded this
GAW> stupid behaviour in their standard, except perhaps ignore it completely.

Why is it "stupid"?

GAW> It seems to me that despite the POSIX blessing on this *BSD-unique
GAW> feature that other systems will continue to ignore POSIX (and *BSD) and
GAW> that no portable application will ever be able to rely on it one way or
GAW> another.  In these kinds of situations I think the only reasonable
GAW> approach is to undo the mistake in the standard and try to encourage
GAW> those fewer unique systems (such as NetBSD) to revert to the traditional
GAW> Unix behavour.  That's the only way I can ever see compatability ever
GAW> being reached on this matter.

Reversion to tradition == de-evolution.  Time goes forward (except, it
would seem, in matters of government and politics in which it stands still
or goes backwards.  But I digress).

No, the choice is this:  Either follow POSIX, or get together and form
a new standard which you can hope will supercede POSIX.

Why is it that anything that seems to reflect BSD instead of "traditional
UNIX systems" ( i.e.  something that makes actual progress!  Remember,
tradition is non-progressive...) makes you look at it as stupid or
worthless or whatever you want to call it?

Personally, the fact that "touch foo/", (for any nonexistent "foo") works
violates the Principle of Least Surprise, from my point of view.  My eyes
are telling me that I should expect "foo" to be a directory, yet:

	$ touch foo/
	$ rmdir foo/
	rmdir: foo: Not a directory
	$

Sorry, I consider this "broken".

				--*greywolf;
--
NetBSD: Stop, Drop, and Load