Re: Linux's interpretation of trailing '/'

Jeremy Fitzhardinge (jeremy@goop.org)
Tue, 15 Dec 1998 09:38:15 -0800 (PST)


On 15-Dec-98 Matthew Kirkwood wrote:
> A trailing / isn't like trailing whitespace - it's like appending '':
> weejock@ferret:~$ cat ''
> cat: : No such file or directory

Which would mean that 'cat foo//bar' should always fail with ENOENT, to be
consistent...

The logic which says that a trailing '/' should work on regular files goes like
this:
- remove all excess trailing and internal slashes from the pathname
(foo///bar// => foo/bar)
- parse pathname

The logic which says that trailing slashes only work on directories says:
- / is a separator, and a delimited empty pathname component is
equivalent to dot
- therefore, parse as if '.'s have been inserted
(foo///bar// => foo/././bar/./.)

The irony is, of course, that the first definition suggests that open ""
doesn't work, and the second says its equivalent to open ".", where as the
exact opposite is true in practice...

J

-
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/