Erik de Castro Lopo wrote: >Richard Jones wrote: > > > >>I think the OCaml one is what I'd reasonably expect actually. >> >>The GNU documentation for basename says: >> >> `basename' removes any leading directory components from NAME. >> >>and a/b/c/ are leading directory components. >> >> > >The word "leading" in the above is at best, ambiguous. > >Regardless of what the documentation says, the behaviour of Ocaml's >basename function is different from the basename program (from the >GNU coreutils package) on my Linux system. > > Interesting point from the Linux basename man page: > There are two different versions of basename() - the POSIX > version > described above, and the GNU version one gets after > #define _GNU_SOURCE > #include > The GNU version never modifies its argument, and returns > the empty > string when path has a trailing slash, and in particular also > when it > is "/". There is no GNU version of dirname(). So there seems to be some confusion, even at Gnu, as to what the proper behavior of this function should be. Brian