[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#12517: 24.2; (file-name-directory "~") returns nil
From: |
Eli Zaretskii |
Subject: |
bug#12517: 24.2; (file-name-directory "~") returns nil |
Date: |
Wed, 26 Sep 2012 09:24:29 +0200 |
> From: Leo <sdl.web@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.