[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#36490: 26.1; directory-files-recursively breaks when it encounters a

From: Lars Ingebrigtsen
Subject: bug#36490: 26.1; directory-files-recursively breaks when it encounters a directory named "~"
Date: Tue, 09 Jul 2019 19:00:13 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

> Sorry, that's not what I meant to say.  I meant to say how would a
> Lisp program know whether (expand-file-name "~/") means the home
> directory or a directory whose name is literally "~"?

Well, we have documented that in expand-file-name "~/" means the home
directory, and I have no problems with that.

"~/" isn't something you'll ever get from functions like
directory-files, so it's not something you'd feed to expand-file-name in
these situations...

> Btw, stuff like (expand-file-name "foo/~/") already does what you
> want, so the problem is only with the leading '~', and can be avoided
> if we avoid that situation.  IOW, why should this example:
>   (expand-file-name "~" "/tmp/")
>      => "/home/larsi"
> determine how directory-files-recursively behaves?

expand-file-name's use case is to (basically) concatenate a directory
name and a file name, but it's used instead of concat because nobody
wants to care about whether the directory name has a trailing slash or

(concat "/tmp/" "foo")
=> "/tmp/foo" ; Good

(concat "/tmp" "foo")
=> "/tmpfoo" ; Bad.

(expand-file-name "foo" "/tmp")
=> "/tmp/foo" ; Yay

That's basically the use case for expand-file-name, and using it has
avoided a lot of basic concatenation problems over the years (because
Emacs allows sloppy handling of directory file names in most

(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no

reply via email to

[Prev in Thread] Current Thread [Next in Thread]