GNU bug report logs - #27982
25.1.50; expand-file-name docstring on how to traverse the filesystem

Previous Next

Package: emacs;

Reported by: Nicolas Richard <youngfrog <at> members.fsf.org>

Date: Sun, 6 Aug 2017 11:39:01 UTC

Severity: minor

Found in version 25.1.50

Done: Nicolas Richard <youngfrog <at> members.fsf.org>

Bug is archived. No further changes may be made.

Full log


Message #17 received at 27982 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Richard <youngfrog <at> members.fsf.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 27982 <at> debbugs.gnu.org
Subject: Re: bug#27982: 25.1.50;
 expand-file-name docstring on how to traverse the filesystem
Date: Wed, 23 Aug 2017 21:18:53 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:
> Crystal ball says that current-directory (which you probably meant to
> be default-directory instead) ends in a slash, in which case remove
> it, and the 2 results will match.

Your crystal ball is working fine. Sorry for leaving that detail out.

FWIW I have (defvaralias 'current-directory 'default-directory) because
I used to forget the name of the variable (and I still do, it seems).

Note however that default-directory ends in a slash when using "emacs
-Q" too.

Ok so now I'm saying that, with the suggestion in the docstring, output
will be different if "dirname" ends in a slash. IOW if it is a
"directory name" as opposed to "directory's file name".

(let ((dirname "/home/youngfrog/"))
   (format "%s versus %s"
      (directory-file-name (file-name-directory dirname))
      (expand-file-name ".." dirname)))

=> output is different

(let ((dirname "/home/youngfrog"))
   (format "%s versus %s"
      (directory-file-name (file-name-directory dirname))
      (expand-file-name ".." dirname)))

=> output the same

With the function calls swapped the output is always similar:

(let ((dirname "/home/youngfrog/"))
   (format "%s versus %s"
      (file-name-directory (directory-file-name dirname))
      (expand-file-name ".." dirname)))

=> output is similar

(let ((dirname "/home/youngfrog"))
   (format "%s versus %s"
      (file-name-directory (directory-file-name dirname))
      (expand-file-name ".." dirname)))

=> output is similar

Nicolas.




This bug report was last modified 7 years and 266 days ago.

Previous Next


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