(expand-file-name "/..")

Marcus Harnisch <[email protected]>
Newsgroups gmane.emacs.xemacs.beta
Message-ID <[email protected]>
Evaluating the expression below leads to strange results that are
contradicting the doc-string which claims that "." and ".." would be
removed.

  (expand-file-name "/..")
  => "/.."

The good news is that at least this is FSF compatible behavior. FSF
Emacs documents this weirdness saying:

“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
filesystem tree, not (expand-file-name ".."  dirname).”

Their suggested workaround is of course not correct in cases where
`dirname' ends with `directory-sep-char':

  (directory-file-name (file-name-directory "/foo/bar/../"))
  => "/foo/bar/.." <<<< WRONG
  
  (expand-file-name "/foo/bar/../")
  => "/foo/"       <<<< RIGHT

It doesn't occur to me why it would be difficult to return

  (expand-file-name "/..")
  => "/"

and

  (expand-file-name "/.")
  => "/"

respectively. History?

Looking at the code I find this comment:
  /* `/../' is the "superroot" on certain file systems.  */

Is there any file system still in use with this concept?

Thanks
Marcus

_______________________________________________
XEmacs-Beta mailing list
[email protected]
http://lists.xemacs.org/mailman/listinfo/xemacs-beta
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.