Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Bug in Filename.basename?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-09-05 (11:10)
From: Erik de Castro Lopo <mle+ocaml@m...>
Subject: Re: [Caml-list] Bug in Filename.basename?
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.

Since I suspect that the basename function is meant to emulate the 
basename program I see the Ocaml function's behaviour as a bug. I
would however discount this if the behaviour of basename on some
other commonly used system (eg *BSD) matched the Ocaml behaviour.

However, here is a comparison chart of what I have tested so far:

                                 "a/b/c"     "a/b/c/"
    Linux basename                 "c"         "c"
    Mac OSX basename               "c"         "c"
    Ocaml Filename.basename        "c"         "."

The behaviour of Ocaml's Filename.basename is the same on Linux and
Mac OSX.

Erik de Castro Lopo