Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] Bug in Filename.basename?
On Wed, Sep 05, 2007 at 06:45:38PM +1000, Erik de Castro Lopo wrote:
> Hi all,
> 
> I think I have found a bug in the above function.
>         Objective Caml version 3.10.0
> 
>     # let x = Filename.basename "a/b/c" ;;
>     val x : string = "c"
>     # let x = Filename.basename "a/b/c/" ;;
>     val x : string = "."
> 
> The first result is fine, but second result is definitely not what
> one would reasonably expect.
> 
> For instance, the basename program in Linux gives:
> 
>     > basename a/b/c/
>     c

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.

Rich.

-- 
Richard Jones
Red Hat