From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#57102: 29.0.50; Peculiar file-name-split edge case Date: Sat, 13 Aug 2022 19:08:00 +0200 Message-ID: <4ECBBAD8-732D-4235-BB7C-003E226543C0@acm.org> References: <87a68cwlnv.fsf@posteo.net> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38924"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , 57102@debbugs.gnu.org To: Philip Kaludercic Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 13 19:09:11 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oMudK-0009uz-MI for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 13 Aug 2022 19:09:10 +0200 Original-Received: from localhost ([::1]:57240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oMudJ-00017H-7D for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 13 Aug 2022 13:09:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oMudC-00015i-Lj for bug-gnu-emacs@gnu.org; Sat, 13 Aug 2022 13:09:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45250) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oMudC-0002lQ-Dk for bug-gnu-emacs@gnu.org; Sat, 13 Aug 2022 13:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oMudC-0006fm-9B for bug-gnu-emacs@gnu.org; Sat, 13 Aug 2022 13:09:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87a68cwlnv.fsf@posteo.net> Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 13 Aug 2022 17:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57102 X-GNU-PR-Package: emacs Original-Received: via spool by 57102-submit@debbugs.gnu.org id=B57102.166041049425591 (code B ref 57102); Sat, 13 Aug 2022 17:09:02 +0000 Original-Received: (at 57102) by debbugs.gnu.org; 13 Aug 2022 17:08:14 +0000 Original-Received: from localhost ([127.0.0.1]:34999 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oMucQ-0006eg-1x for submit@debbugs.gnu.org; Sat, 13 Aug 2022 13:08:14 -0400 Original-Received: from mail1472c50.megamailservers.eu ([91.136.14.72]:58268 helo=mail102c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oMucO-0006eR-1V for 57102@debbugs.gnu.org; Sat, 13 Aug 2022 13:08:13 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1660410484; bh=dGkMfrDSLd9WQCe2mCnRGSDAQJfOR0pgX7ACy2fAN+8=; h=From:Subject:Date:Cc:To:From; b=hJH2n+FA0YM13gC5XEmnnhVI1KdufJswKC0KUDC/UjECjGE2771tVEkfPAvqojCy6 lioBOYWzA5RI7RjTv44Kb+sUlRHOj663W1y5Vftbxw2Y5W4UsoqCNdk/Nu82UIMl1L jKK4AwG4iv9BuFvkKmPdJpdQnVTe4pTmUl630kac= Feedback-ID: mattiase@acm.or Original-Received: from smtpclient.apple (c188-150.188-179.bredband.tele2.se [188.150.188.179] (may be forged)) (authenticated bits=0) by mail102c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 27DH806s066844; Sat, 13 Aug 2022 17:08:02 +0000 X-Mailer: Apple Mail (2.3654.120.0.1.13) X-CTCH-RefID: str=0001.0A782F23.62F7DA74.0048, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-Origin-Country: SE X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:239570 Archived-At: The current behaviour of file-name-split is based on a purely textual = splitting on "/" which isn't as useful as basing it on actual file name = components. For instance, the root component of a Posix file name is = "/", not "". Looking at other languages and libraries is very much = encouraged; they vary a lot in the amount of thought that has gone into = their design. Ideally we'd have a split function (the name is a placeholder for now) = where: (split "/a/b/c") -> ("/" "a" "b" "c") (split "a/b/c/") -> ("a" "b" "c" "") (split "/") -> ("/" "") and, because repeated slashes mean the same thing as a single one in = Posix except at the beginning, (split "//a//b//") -> ("//" "a" "b" "") An accompanying join operation would be the inverse, sort of: (join "/" "a" "b" "c") -> "/a/b/c" (join "a" "b" "") -> "a/b/" where empty strings are ignored except at the end: (join "" "a" "" "" "b") -> "a/b" (join "a" "b" "" "") -> "a/b/" Pre-joined chunks can be joined too: (join "/a/b" "c/d/" "e") -> "/a/b/c/d/e" Maybe components with a leading slash start over from the root: (join "/" "a" "/b" "c") -> "/a/b/c" ? (join "/" "a" "/b" "c") -> "/b/c" ? Python's os.path.join does the latter; it's probably a good idea. Now `file-name-concat` almost works like `join` above but not quite. = Adding a new function is likely better than making compromises. On Windows I'd expect that (split "c:\\a\\b") -> ("c:\\" "a" "b") (split "c:\\") -> ("c:\\" "") but it's a bit complicated and then we have all the UNC path variants to = deal with; a platform expert should be consulted.