Browse thread
Bug in Filename.basename?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2007-09-05 (12:10) |
From: | Olivier Andrieu <oandrieu@n...> |
Subject: | Re: [Caml-list] Bug in Filename.basename? |
On 9/5/07, Richard Jones <rich@annexia.org> wrote: > 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. POSIX has a precise definition of its basename() function: http://www.opengroup.org/onlinepubs/009695399/functions/basename.html and it indeed says that trailing / are to be removed. -- Olivier