Unlike path separation via basename and dirname, there is no utility to concatenate paths. The naive bash implementation:
"${basename}/${dirname}"
is not correct in the case that the basename is "//" (// -> ///), OR if
basename is "/" and dirname does not begin with a slash (/ -> //). (see
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_271:
"Multiple successive <slash> characters are considered to be the same as one
<slash>, except for the case of exactly two leading <slash> characters.")
So for a fully correct path concatenation operation, these conditions must be
checked, which can lead to a great multiplicity of repeated code in
applications, and possibly subtle bugs if the naive approach is taken.
(Attached is a source file I recently wrote).
Posix needs a shell command (1) and a library function (3) that correctly
handle path concatenation, I believe.
Hope this is well received, and sorry if it is already under discussion - I did
not find any threads on it in my cursory search.
Jefferson Carpenter
path.cpp
Description: Binary data
