bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8035: Processing of .. in a file path after going thru symlink


From: Eli Zaretskii
Subject: bug#8035: Processing of .. in a file path after going thru symlink
Date: Thu, 26 Aug 2021 20:30:29 +0300

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: slpnabble@blackberry-hill.com,  8035@debbugs.gnu.org
> Date: Thu, 26 Aug 2021 19:24:28 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > expand-file-name also normalizes file names, though.  Which is also
> > needed in some use cases, e.g. when the /foo/bar/ isn't accessible,
> > but /foo/ is, in which case failing to normalize /foo/bar/../quux
> > could fail some file I/O function.
> 
> Hm, yes, that's a point...

The OP's use case is clearly documented in the ELisp manual:

     Note also that ‘expand-file-name’ does not follow symbolic links at
     any level.  This results in a difference between the way
     ‘file-truename’ and ‘expand-file-name’ treat ‘..’.  Assuming that
     ‘/tmp/bar’ is a symbolic link to the directory ‘/tmp/foo/bar’ we
     get:

          (file-truename "/tmp/bar/../myfile")
               ⇒ "/tmp/foo/myfile"
          (expand-file-name "/tmp/bar/../myfile")
               ⇒ "/tmp/myfile"

     If you may need to follow symbolic links preceding ‘..’, you should
     make sure to call ‘file-truename’ without prior direct or indirect
     calls to ‘expand-file-name’.  *Note Truenames::.

So I think we need to use file-truename if we want to support such
uses of symlinks in "M-x compile" etc.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]