From: Markus E L <ls-ocaml-2006@m-e-leypold.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Bug in Filename.basename?
Date: Wed, 05 Sep 2007 15:06:03 +0200 [thread overview]
Message-ID: <wwy7flcldw.fsf@hod.lan.m-e-leypold.de> (raw)
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")
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
next prev parent reply other threads:[~2007-09-05 13:01 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-05 8:45 Erik de Castro Lopo
2007-09-05 10:41 ` [Caml-list] " Richard Jones
2007-09-05 11:10 ` Erik de Castro Lopo
2007-09-05 11:25 ` Oliver Bandel
2007-09-05 12:00 ` Erik de Castro Lopo
2007-09-05 13:06 ` Markus E L
2007-09-05 20:39 ` Oliver Bandel
2007-09-05 21:03 ` Oliver Bandel
2007-09-06 4:52 ` skaller
2007-09-06 7:09 ` Christophe Raffalli
2007-09-06 9:51 ` Oliver Bandel
2007-09-06 9:32 ` Markus E L
2007-09-06 10:00 ` Oliver Bandel
2007-09-05 12:15 ` Mattias Engdegård
2007-09-05 20:54 ` Oliver Bandel
2007-09-05 12:37 ` Brian Hurt
2007-09-05 13:06 ` Markus E L [this message]
2007-09-05 12:10 ` Olivier Andrieu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=wwy7flcldw.fsf@hod.lan.m-e-leypold.de \
--to=ls-ocaml-2006@m-e-leypold.de \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox