GNU bug report logs - #36490
26.1; directory-files-recursively breaks when it encounters a directory named "~"

Previous Next

Package: emacs;

Reported by: Erik Hahn <erik_hahn <at> gmx.de>

Date: Wed, 3 Jul 2019 18:09:01 UTC

Severity: minor

Tags: confirmed, fixed

Found in version 26.1

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 36490 <at> debbugs.gnu.org, erik_hahn <at> gmx.de
Subject: bug#36490: 26.1; directory-files-recursively breaks when it encounters a directory named "~"
Date: Tue, 09 Jul 2019 18:35:46 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Mon, 08 Jul 2019 23:08:46 +0200
> Cc: 36490 <at> debbugs.gnu.org
> 
> Actually, the doc string of expand-file-name is either wrong, or the
> implementation is.
> 
> It says:
> 
> ---
> An initial ‘~/’ expands to your home directory.
> An initial ‘~USER/’ expands to USER’s home directory.
> ---
> 
> Assuming the "An initial" refers to the first parameter, then
> 
> (expand-file-name "~/" "/tmp/")
> => "/home/larsi/"
> 
> works as advertised, but
> 
> (expand-file-name "~" "/tmp/")
> => "/home/larsi"
> 
> is a different thing: "~" is a perfectly valid file name, so having this
> function map that to something else is just...  wrong.

If you want "~" to be interpreted literally, you need to protect it
with "/:".

> (expand-file-name "~larsi" "/tmp/")
> => "/home/larsi"
> 
> is the same: Also wrong and undocumented.

Why would we want to document that?

> The doc string continues with further confusion:
> 
> ---
> See also the function ‘substitute-in-file-name’.
> ---
> 
> See it for...  what?

For expanding environment variables, and for the special effect of
"//" etc.

> So what to do here?  I think the current, undocumented
> 
> (expand-file-name "~" "/tmp/")
> => "/home/larsi"
> 
> must surely be an error, and that should be fixed instead of the
> callers?  Opinions?

It is not an error.




This bug report was last modified 5 years and 315 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.