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=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 71A72BC6B for ; Thu, 6 Sep 2007 06:58:47 +0200 (CEST) Received: from ipmail02.adl2.internode.on.net (ipmail02.adl2.internode.on.net [203.16.214.141]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l864wjtC030063 for ; Thu, 6 Sep 2007 06:58:46 +0200 X-IronPort-AV: E=Sophos;i="4.20,213,1186324200"; d="scan'208";a="182613177" Received: from ppp121-44-82-249.lns10.syd6.internode.on.net (HELO [192.168.1.201]) ([121.44.82.249]) by ipmail02.adl2.internode.on.net with ESMTP; 06 Sep 2007 14:22:47 +0930 Subject: Re: [Caml-list] Bug in Filename.basename? From: skaller To: Oliver Bandel Cc: caml-list@inria.fr In-Reply-To: <1189024766.46df13fed404a@webmail.in-berlin.de> References: <20070905184538.88ada4e8.mle+ocaml@mega-nerd.com> <20070905104127.GB24323@furbychan.cocan.org> <20070905211013.b53cf46b.mle+ocaml@mega-nerd.com> <1188991526.46de922610e05@webmail.in-berlin.de> <20070905220031.5995251d.mle+ocaml@mega-nerd.com> <1189024766.46df13fed404a@webmail.in-berlin.de> Content-Type: text/plain Date: Thu, 06 Sep 2007 14:52:45 +1000 Message-Id: <1189054365.9224.74.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 46DF8905.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; bug:01 basename:01 0200,:01 bandel:01 ocaml's:01 dirname:01 basename:01 ocaml:01 ocaml's:01 semantics:01 ocaml:01 libref:01 dirname:01 chdir:01 chdir:01 On Wed, 2007-09-05 at 22:39 +0200, Oliver Bandel wrote: > The behaviour of OCaml's > Filename.concat (Filename.dirname) (Filename.basename) > makes sense to me. IMHO it should be done the way OCaml does it. You fail to understand that this requirement is ALSO met by Posix C functions and bash. The difference is Ocaml's function doesn't have well specified semantics, whereas Posix is an International Standard backed by the United Nations. The Ocaml manual says this: http://caml.inria.fr/pub/docs/manual-ocaml/libref/Filename.html "Moreover, after setting the current directory to dirname name (with Sys.chdir), references to basename name (which is a relative file name) designate the same file as name before the call to Sys.chdir. And that is in fact rubbish: filename functionality is not directly related to the filesystem, because the files need not exist (or may not agree with the specified name in kind). Other than this text, the Ocaml manual in fact does NOT specify what happens if there is a trailing / character. Posix does. So you're wrong on all counts here. There's no excuse for Ocaml not doing one of: a) following the Posix rules on a Posix platform AND saying so b) following other rules, AND describing them In general, a WEAK specification is good, and the Ocaml specification here is weak: it doesn't specify what happens if there is a trailing / character. However in THIS case the user may be surprised at what it actually does. Indeed, the OP Eric was surprised! The fact is I AGREE WITH YOUR ARGUMENT if you would be arguing that it is sensible to consider that since in Unix you cannot tell if a filename refers to a directory or a non-directory file, a SENSIBLE CONVENTION is to put a / at the end if you mean a directory. I agree, that's sensible. But it doesn't matter. The purpose of the Filename module is to process filenames in a way that closely matches the normal behaviour of native functions on the native platform .. and the interpretation above IS NOT DOCUMENTED. -- John Skaller Felix, successor to C++: http://felix.sf.net