views:

22

answers:

1

The question is really simple: should a path to a directory always contain a slash at the end?

say: /path/to/directory/ over /path/to/directory.

Linux/Unix seem to accept both. Most applications and libraries on linux follow this. e.g. a <Directory /home/someproject/foo/code> works just fine.

In programming, say PHP I can do a dir on both directories with a slash-at-the-end. and those without. PHP's documentation has examples that omit the / http://www.php.net/manual/en/class.dir.php

In Ruby the same: I can use /path/to/dir/ and /path/to/dir in Dir?

What is the "best practice"? Is there a performance-penalty when using one of both? Are there edge-cases where both work different, or one of both will break?

+1  A: 

I use the trailing slash for consistency. If I am building a dynamic path/name, I like to see the trailing slash to indicate I am done any construction of that part of the path. This coincides with my decision to also use trailing slashes for web locations. Some people's thoughts can found at http://www.fiftyfoureleven.com/weblog/search-engines/trailing-slashes-best-practice

Edward Leno