unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: file-exists-p on empty string
@ 2019-02-27 20:07 lg.zevlg
  2019-02-27 21:18 ` Stefan Monnier
  0 siblings, 1 reply; 34+ messages in thread
From: lg.zevlg @ 2019-02-27 20:07 UTC (permalink / raw)
  To: monnier; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 319 bytes --]


> So the (not (string-empty-p fn)) test just reflects the tool's semantics and is not an artifact of some suboptimal behavior of file-exists-p.
I gree, but there is not a line about empty strings in doc-string.  It is great that this is mentioned in documentation, but anyway behaviour was quite unexpected

--
lg

[-- Attachment #2: Type: text/html, Size: 858 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread
* Re: file-exists-p on empty string
@ 2019-02-27 22:09 lg.zevlg
  2019-02-27 22:23 ` Drew Adams
  0 siblings, 1 reply; 34+ messages in thread
From: lg.zevlg @ 2019-02-27 22:09 UTC (permalink / raw)
  To: monnier; +Cc: emacs-devel

> The problem is that docstrings describe the behavior of a specific function, so they usually don't mention the more general aspects that affect all functions of a given subsystem, such as here the general treatment of the empty string when used as a file name. Otherwise, every file-name-manipulating function would have to repeat this information in its docstring.

So, maybe FILENAME argument at least could be renamed to NAME to give at least some hint that this is not a filename, but just a name hint which will be expanded and canonised to real filename?

--
lg


^ permalink raw reply	[flat|nested] 34+ messages in thread
* file-exists-p on empty string
@ 2019-02-27 12:29 Evgeny Zajcev
  2019-02-27 14:15 ` Michael Albinus
                   ` (2 more replies)
  0 siblings, 3 replies; 34+ messages in thread
From: Evgeny Zajcev @ 2019-02-27 12:29 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 438 bytes --]

It was quite surprising for me that

  (file-exists-p "")
  ==> t

I thought that `file-exists-p` resembles stat, such as

  $ stat ""
  No such file or directory

This is because `file-exists-p` uses `expand-file-name`, which returns
current directory for empty string

Would not it be more correct for `file-exists-p` to return `nil` for empty
string, and if someone wants current directory he will use "." as filename?

Thanks

-- 
lg

[-- Attachment #2: Type: text/html, Size: 796 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2019-03-09  8:48 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-27 20:07 file-exists-p on empty string lg.zevlg
2019-02-27 21:18 ` Stefan Monnier
2019-02-27 22:01   ` Drew Adams
2019-02-28  3:24     ` Stefan Monnier
2019-03-06  9:51   ` Michael Albinus
2019-03-08  6:11     ` Stefan Monnier
2019-03-09  8:48       ` Michael Albinus
  -- strict thread matches above, loose matches on Subject: below --
2019-02-27 22:09 lg.zevlg
2019-02-27 22:23 ` Drew Adams
2019-02-27 22:41   ` Evgeny Zajcev
2019-02-27 23:23     ` Drew Adams
2019-02-28  0:08       ` Evgeny Zajcev
2019-02-28  1:16     ` Stefan Monnier
2019-02-27 12:29 Evgeny Zajcev
2019-02-27 14:15 ` Michael Albinus
2019-02-27 15:29   ` Troy Hinckley
2019-02-27 15:43   ` Robert Pluim
2019-02-27 16:01     ` Michael Albinus
2019-02-27 16:55       ` Eli Zaretskii
2019-02-27 18:09         ` Michael Albinus
2019-02-27 16:11     ` Eli Zaretskii
2019-02-27 16:16       ` Robert Pluim
2019-02-27 16:30     ` Andreas Schwab
2019-02-27 19:40     ` lg.zevlg
2019-02-27 15:53 ` Stefan Monnier
2019-02-27 16:00   ` Robert Pluim
2019-02-27 16:15     ` Stefan Monnier
2019-02-27 16:09 ` Eli Zaretskii
2019-02-27 18:42   ` lg.zevlg
2019-02-27 18:46     ` Eli Zaretskii
2019-02-27 19:04       ` lg.zevlg
2019-02-27 19:16         ` Eli Zaretskii
2019-02-27 19:29           ` lg.zevlg
2019-02-27 19:30         ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).