From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.devel Subject: Re: expand-file-name, DOS/Windows, and directory separator Date: Tue, 15 Feb 2022 12:46:43 -0800 Message-ID: <87k0dvdfik.fsf@ericabrahamsen.net> References: <87czjodn8m.fsf@ericabrahamsen.net> <87wnhvdim4.fsf@ericabrahamsen.net> <83o8373ntc.fsf@gnu.org> <87sfsjdgz7.fsf@ericabrahamsen.net> <83mtir3mjy.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33074"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) To: emacs-devel@gnu.org Cancel-Lock: sha1:5FEx33AYEAeMh35nSbHPo0lxcGE= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Feb 15 21:48:51 2022 Return-path: Envelope-to: ged-emacs-devel@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 1nK4kj-0008Rk-Ps for ged-emacs-devel@m.gmane-mx.org; Tue, 15 Feb 2022 21:48:49 +0100 Original-Received: from localhost ([::1]:50936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nK4ki-00089J-E2 for ged-emacs-devel@m.gmane-mx.org; Tue, 15 Feb 2022 15:48:48 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:56578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK4it-0007Qt-KO for emacs-devel@gnu.org; Tue, 15 Feb 2022 15:46:55 -0500 Original-Received: from ciao.gmane.io ([116.202.254.214]:55888) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nK4ir-00028u-FJ for emacs-devel@gnu.org; Tue, 15 Feb 2022 15:46:54 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1nK4ip-0005nN-1s for emacs-devel@gnu.org; Tue, 15 Feb 2022 21:46:51 +0100 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:286352 Archived-At: Eli Zaretskii writes: >> From: Eric Abrahamsen >> Date: Tue, 15 Feb 2022 12:15:08 -0800 >> >> >> (file-name-split (expand-file-name "/")) >> > >> > file-name-split is one of the functions that support both styles of >> > slashes, so you don't need to call expand-file-name at all. (And "/" >> > is not really an absolute file name on Windows anyway). >> >> The `expand-file-name' is in there to collapse multiple consecutive >> directory separators, which happens in the wild, as `file-name-split' >> doesn't do that by itself. > > Then do call expand-file-name, but you don't need to assume anything > about slashes in the result. Got it. >> Just running this, where I've doubled the slashes so as not to raise >> an error: >> >> (file-name-split "C:\\Users\\eric\\random") >> >> Just returns the whole string. > > I bet you did that on Unix? Because here on MS-Windows it returns the > expected > > ("" "Users" "eric" "random") As I was hoping it would! But yes, I only have unix-like boxes to test on. >> This code has to handle all the weirdness of different systems and >> filesystem layouts and search engines, so I'm being a little paranoid >> about it. > > You don't need to be paranoid. Emacs's file-name related primitives > are supposed to handle file names on all the supported systems; > anything else is a bug that should be fixed. Ignorance breeds magical thinking :) Thanks for the reassurance, I'll go ahead and update this.