Re: Linux's interpretation of trailing '/'

Michael H. Warfield (mhw@wittsend.com)
Tue, 15 Dec 1998 09:06:29 -0500 (EST)


Matthew Kirkwood enscribed thusly:
> On Mon, 14 Dec 1998, Jeremy Fitzhardinge wrote:

> > A friend of mine pointed out that Linux's interpretation of a trailing
> > '/' on ordinary files differs from traditional Unix behaviour.

> > On Linux:
> > $ touch z
> > $ cat z/
> > cat: z/: Not a directory

> > All quite reasonable and logical, but Solaris behaves this way:

> > : aegis:pts/4; echo foo > z
> > : aegis:pts/4; cat z/
> > foo

> > Now I would say that Linux makes complete sense, and the Solaris
> > behaviour looks like sloppy handling to mee. My friend who raised the
> > issue points out that its consistent if you regard '/' as a delimiter in
> > the same way as whitespace is delimiter in /bin/sh, and consequently you
> > should just ignore trailing '/' as you would trailing whitespace on a
> > command like.

> A trailing / isn't like trailing whitespace - it's like appending '':
> weejock@ferret:~$ cat ''
> cat: : No such file or directory

Not...

A standalone separator is a totally different issue...

Try this:

alcove:~$ echo foo > foo
alcove:~$ cat foo
foo
alcove:~$ cat foo''
foo
alcove:~$

This is also not the same thing since '' is not a character at all...
But appending a '/' is appending a character, and that's a difference.

I also think that Linux handles trailing slashes in a preferable
maner. Is there anything in POSIX which speaks to this issue? If there
is, it should be settled and we can say one is right and one is not. If
not, it's vendor implimentation dependent and we can all claim to be "right".

> Matthew.

Mike

-- 
 Michael H. Warfield    |  (770) 985-6132   |  mhw@WittsEnd.com
  (The Mad Wizard)      |  (770) 925-8248   |  http://www.wittsend.com/mhw/
  NIC whois:  MHW9      |  An optimist believes we live in the best of all
 PGP Key: 0xDF1DD471    |  possible worlds.  A pessimist is sure of it!

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/