GNU bug report logs - #12517
24.2; (file-name-directory "~") returns nil

Previous Next

Package: emacs;

Reported by: Leo <sdl.web <at> gmail.com>

Date: Wed, 26 Sep 2012 02:38:02 UTC

Severity: normal

Found in version 24.2

Done: Leo <sdl.web <at> gmail.com>

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: Leo <sdl.web <at> gmail.com>
Cc: 12517 <at> debbugs.gnu.org
Subject: bug#12517: 24.2; (file-name-directory "~") returns nil
Date: Wed, 26 Sep 2012 09:24:29 +0200
> From: Leo <sdl.web <at> gmail.com>
> Date: Wed, 26 Sep 2012 10:35:10 +0800
> 
> I was bitten by this corner case that (file-name-directory "~") returns
> nil.

As does (file-name-directory "a").

> I wonder if this is a bug/oversight?

I think it is neither.  file-name-directory works on the syntax of its
argument, not on its semantics.  The ELisp manual says:

 -- Function: file-name-directory filename
     This function returns the directory part of FILENAME, as a
     directory name (*note Directory Names::), or `nil' if FILENAME
     does not include a directory part.

"FILENAME does not include a directory part" means literally that: the
string FILENAME must _include_ a directory part for
file-name-directory to return a non-nil result.

If you want the directory of its argument, even if the argument is
given as any kind of shorthand, run that argument through
expand-file-name first.




This bug report was last modified 12 years and 245 days ago.

Previous Next


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