I'm writing a library for manipulation Unix path strings. That being the case, I need to understand a few obscure corners of the syntax that most people wouldn't worry about.
For example, as best as I can tell, it seems that foo/bar
and foo//bar
both point to the same place.
Also, ~
usually stands for the user's home directory, but what if it appears in the middle of a path? What happens then?
These and several dozen other obscure questions need answering if I'm going to write code which handles every possible case correctly. Does anybody know of a definitive reference which explains the exact syntax rules for this stuff?
(Unfortunately, searching for terms like "Unix path syntax" just turns up a million pages discussing the $PATH
variable... Heck, I'm even struggling to find suitable tags for this question!)
~
) is covered in How linux handles multiple path separators (/home////username///file). The closest thing to a normative reference would be the POSIX or Single Unix specification — not easy reading. – Gilles 'SO- stop being evil' Apr 19 '14 at 23:01