|
From: | Gregory Heytings |
Subject: | Re: Why does (file-exists-p "") return t? |
Date: | Thu, 09 Feb 2023 10:56:49 +0000 |
I just noticed that (file-exists-p “”) returns t on my system (Emacs 28.2 on Arch Linux).I am not familiar with Emacs’ file handling internals, so the answer might be obvious.However, I did not find any mention of this case in the docstring or the Elisp manual.
When the argument to file-exists-p is not an absolute file name, it is understood as being relative to default-directory. Therefore with an empty string, file-exists-p checks whether default-directory exists, which is normally the case. But
(let ((default-directory "/nonexistent")) (file-exists-p "")) returns nil.
[Prev in Thread] | Current Thread | [Next in Thread] |