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


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Nicolas Richard <youngfrog <at> members.fsf.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#27982: closed (25.1.50; expand-file-name docstring on how to
 traverse the filesystem)
Date: Wed, 30 Aug 2017 15:45:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Wed, 30 Aug 2017 17:43:51 +0200
with message-id <86efrtysaw.fsf <at> members.fsf.org>
and subject line Re: bug#27982: 25.1.50; expand-file-name docstring on how to traverse the filesystem
has caused the debbugs.gnu.org bug report #27982,
regarding 25.1.50; expand-file-name docstring on how to traverse the filesystem
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
27982: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=27982
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Nicolas Richard <youngfrog <at> members.fsf.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.1.50; expand-file-name docstring on how to traverse the filesystem
Date: Sun, 06 Aug 2017 13:38:32 +0200
[Message part 3 (text/plain, inline)]
The docstring of expand-file-name suggest
(directory-file-name (file-name-directory dirname))
to traverse a directory

This looks wrong to me, e.g.
(list current-directory
      (directory-file-name (file-name-directory current-directory)))
 => ("/home/youngfrog/" "/home/youngfrog")

I think it should be (file-name-directory (directory-file-name dirname))
instead. Then the example becomes:

(list current-directory
      (file-name-directory (directory-file-name current-directory)))
 => ("/home/youngfrog/" "/home/")

Am I overlooking something ?
Is this patch ok to commit ?

In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu)
 of 2016-11-15 built on phie-fixe
Repository revision: f994c2046588b168c1a4a900879cdffaf9d02f01
Windowing system distributor 'The X.Org Foundation', version 11.0.11804000
System Description:	Ubuntu 16.04.2 LTS

[0001-src-fileio.c-Fexpand_file_name-fix-suggestion-to-tra.patch (text/x-diff, inline)]
From 607e1445cfb1294c14af38cb4c39a93683e5671d Mon Sep 17 00:00:00 2001
From: Nicolas Richard <youngfrog <at> members.fsf.org>
Date: Sun, 6 Aug 2017 13:14:41 +0200
Subject: [PATCH] * src/fileio.c (Fexpand_file_name): fix suggestion to
 traverse the filesystem

---
 src/fileio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/fileio.c b/src/fileio.c
index c3b2be7..28d619c 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -776,7 +776,7 @@ See also the function `substitute-in-file-name'.
 For technical reasons, this function can return correct but
 non-intuitive results for the root directory; for instance,
 \(expand-file-name ".." "/") returns "/..".  For this reason, use
-\(directory-file-name (file-name-directory dirname)) to traverse a
+\(file-name-directory (directory-file-name dirname)) to traverse a
 filesystem tree, not (expand-file-name ".."  dirname).  */)
   (Lisp_Object name, Lisp_Object default_directory)
 {
-- 
2.7.4

[Message part 5 (message/rfc822, inline)]
From: Nicolas Richard <youngfrog <at> members.fsf.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 27982-done <at> debbugs.gnu.org
Subject: Re: bug#27982: 25.1.50;
 expand-file-name docstring on how to traverse the filesystem
Date: Wed, 30 Aug 2017 17:43:51 +0200
Hi Eli,

Thanks for your help but let me close this.

I initially thought it was "obviously wrong", but it is not. I think the
wording is slightly misleading (e.g. "dirname" vs "dir-as-file-name"),
but nothing important.

Nicolas.

Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Nicolas Richard <youngfrog <at> members.fsf.org>
>> Cc: 27982 <at> debbugs.gnu.org
>> Date: Wed, 23 Aug 2017 21:18:53 +0200
>>
>> Ok so now I'm saying that, with the suggestion in the docstring, output
>> will be different if "dirname" ends in a slash.
>
> Of course.  directory-file-name and file-name-directory look at the
> slashes, so having one more slash at the end changes everything.
> There's nothing new here.
>
> So where do we go from here, in the context of this bug report?  What
> would you propose to change, where, and why?
>
> Thanks.


--


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.