Reputation: 1853
I want to write a POSIX compliant function to join paths. I've read the Pathname Resolution section. I'm not sure what should be the result when the first path starts with "..".
If I join "../abc/def" and "xyz", of the following, which should be the result in your opinion? Why?
abc/def/xyz
/abc/def/xyz
../abc/def/xyz
Something else?
Upvotes: 0
Views: 311
Reputation: 531758
..
is an actual file system entry referring to the parent of the directory it is contained in. Simply joining two paths should not depend on any context, such as the identity of the current directory. ../abc/def/xyz
is the correct answer lacking such context.
Upvotes: 1