unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: <tomas@tuxteam.de>
To: 69438@debbugs.gnu.org
Subject: bug#69438: basename faulty with nul and suffix
Date: Wed, 28 Feb 2024 06:31:52 +0100	[thread overview]
Message-ID: <Zd7FSMbnRaDQl8EP@tuxteam.de> (raw)
In-Reply-To: <Zd5Cws6SfuISHlad@fysh.org>

[-- Attachment #1: Type: text/plain, Size: 1270 bytes --]

On Tue, Feb 27, 2024 at 08:14:58PM +0000, Zefram via Bug reports for GUILE, GNU's Ubiquitous Extension Language wrote:
> Trying out the basename function in Guile 3.0.9:
> 
> scheme@(guile-user)> (basename "foo/bar")
> $1 = "bar"
> scheme@(guile-user)> (basename "foo/bar" "r")
> $2 = "ba"
> scheme@(guile-user)> (basename "foo/bar" "x")
> $3 = "bar"
> scheme@(guile-user)> (basename "foo/bar\0baz/quux")
> $4 = "bar"
> scheme@(guile-user)> (basename "foo/bar\0baz/quux" "r")
> $5 = "bar"
> scheme@(guile-user)> (basename "foo/bar\0baz/quux" "x")
> $6 = "ba"
> 
> The first three cases here show the function operating correctly on a
> mundane pathname string.

Hm. The functions are clearly designated as POSIX. In POSIX, \0 is
explicitly excluded as a legal character in paths [1] [2]. I guess
the implementation is just passing the buck to the OS's basename(3).

Arguably, it'd be friendlier for the function to throw an error,
but then, it'd be inconsistent with the OS. You can't win :-)

Perhaps, a note in the docs wouldn't harm, though.

Cheers

[1] https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap03.html#tag_03_266
[2] https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap03.html#tag_03_169
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

      reply	other threads:[~2024-02-28  5:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27 20:14 bug#69438: basename faulty with nul and suffix Zefram via Bug reports for GUILE, GNU's Ubiquitous Extension Language
2024-02-28  5:31 ` tomas [this message]

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

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zd7FSMbnRaDQl8EP@tuxteam.de \
    --to=tomas@tuxteam.de \
    --cc=69438@debbugs.gnu.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).