Subject: bug#57102: 29.0.50; Peculiar file-name-split edge case

From: Lars Ingebrigtsen <[email-masked]>
Date: Mon, 15 Aug 2022 07:54:34 +0200

Philip Kaludercic <[email-masked]> writes:

> Grepping through emacs.git to see where file-name-split is used, it
> seems that all it would change in most cases you'd just require an
> additional (cdr ...).  At the same time, there is already an instance in
> gnus-search.el that deals with the issue I brought up with the empty
> strings.

Stepping back a bit, the use case for file-name-split is basically "give
me the components of this file name", but it's trying to return
something that can unambiguously be put back together again to get to
the original string.  Perhaps that's misguided, and the interpretation
of the result be left up to the caller.

That is, perhaps what we want is

(file-name-split "a/b")
=> '("a" "b")

(file-name-split "a/b/")
=> '("a" "b")

(file-name-split "/a/b")
=> '("a" "b")

(file-name-split "//a////b////")
=> '("a" "b")

I'm not sure what

(file-name-split "c:/a/b")

on Windows should return in that case, though.