Subject: Re: Linux emulation and mkdir with trailing /
To: None <tech-kern@netbsd.org>
From: Greg A. Woods <woods@weird.com>
List: tech-kern
Date: 09/25/2000 11:56:42
[ On Monday, September 25, 2000 at 12:54:45 (+0200), Alan Barrett wrote: ]
> Subject: Re: Linux emulation and mkdir with trailing /
>
> But if I ever type a name with a trailing slash, then I intend that name
> to be interpreted as a directory, and I expect to get an error if it
> is a (non-directory) file.  For example, if foo exists as a file and I
> say "mv foo bar/", then I want to get an error if bar does not already
> exist as a directory; I certainly don't want to end up with bar as a
> file.

Why not?  If you don't know for sure that "bar" is an existing directory
file before you run such a command then why would you expect the
trailing '/' to do anything special?  If you really want to get an error
from a bare system call when you refer to a directory that does not
exist then you should be explicit about it's property as a directory and
refer to it as:  "bar/."

>  Similarly, if I type "install myprogram /usr/local/bin/" but
> /usr/local/bin does not exist, then I want an error message, I don't
> want to end up with /usr/local/bin as an executable program.

I think you're asking for applications to behave in ways that the
underlying system does not truly support.

As I said earlier, I will support the idea that a shell might trigger a
failure during filename expansion if a trailing slash on a pathname does
not expand to match an existing character (and thus that trailing
slashes must become glob characters to trigger filename expansion, of
course).  I would only want this feature to be active in interactive
mode for my shell though.....

However I do not want the system to try to be any "smarter" than the way
the original system behaved.  There be dragons in that direction!  The
elegance of stripping all trailing slashes is the expected, traditional,
and probably standard behaviour, and it does not remove the ability to
get an error if a directory you specify does not exist, even without
special hacks to the shell expansion tools.  Inconsistency between
system variants, especially at such a low level, is a bad thing all by
itself too.

In the mean time if you really want to specify /usr/local/bin as a
directory then refer explicitly to it as the directory which it really
should be, i.e. as "/usr/local/bin/.".  This is, after all, the only
portable way to achieve your expectations anyway.

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods@acm.org>      <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>