From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 4109FBC6C for ; Wed, 5 Sep 2007 15:01:49 +0200 (CEST) Received: from server2.thinkcrime.de (server2.thinkcrime.de [213.133.110.149]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l85D1m5V009466 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 5 Sep 2007 15:01:49 +0200 Received: from hod-sarge-2005-10.lan.m-e-leypold.de (dslb-088-074-042-110.pools.arcor-ip.net [88.74.42.110]) (Authenticated sender: hod-sarge-2005-10@server2) by server2.thinkcrime.de (Postfix) with ESMTP id 5ACE090025F for ; Wed, 5 Sep 2007 15:01:23 +0200 (CEST) Received: by hod-sarge-2005-10.lan.m-e-leypold.de (Postfix, from userid 1003) id 28A0B37963; Wed, 5 Sep 2007 15:06:03 +0200 (CEST) To: caml-list@inria.fr Subject: Re: [Caml-list] Bug in Filename.basename? References: <20070905184538.88ada4e8.mle+ocaml@mega-nerd.com> <20070905104127.GB24323@furbychan.cocan.org> <20070905211013.b53cf46b.mle+ocaml@mega-nerd.com> From: Markus E L Organization: N/A Date: Wed, 05 Sep 2007 15:06:03 +0200 In-Reply-To: <20070905211013.b53cf46b.mle+ocaml@mega-nerd.com> (Erik de Castro Lopo's message of "Wed, 5 Sep 2007 21:10:13 +1000") Message-ID: User-Agent: Some cool user agent (SCUG) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Miltered: at concorde with ID 46DEA8BC.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; bug:01 basename:01 markus:01 ocaml:01 basename:01 ocaml's:01 ocaml:01 bug:01 ocaml's:01 opengroup:01 onlinepubs:01 opengroup:01 onlinepubs:01 markus:01 wrote:01 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. > > 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. But tmp/:$ cat /etc/hosts/ cat: /etc/hosts/: Not a directory Most shell tools interpret the trailing slash as meaning '[...]/.' . I'd definitely vote for Linux or Mac OS/X shell basename being buggy rather than ocamls. Trailing shlashes have meaning (actually I think a trailing slash should result in a "badly formed path error" but this convention is probably too deeply entrenched now to fight it). The standards, though: http://www.opengroup.org/onlinepubs/009695399/utilities/basename.html - If there are any trailing slash characters in string, they shall be removed. http://www.opengroup.org/onlinepubs/009695399/functions/basename.html - The same, but only given by example, not by specification Given how most shell tools interpret trailing slashes I think it's rather a problem of the standard to introduce inconsistencies in order to conform to existing practice. In those cases I consider it better not to orient towards the standard (and who says that OCaml basename has to work like POSIX or Single Unix basename?). Regards -- Markus