GNU bug report logs -
#33564
Incorrect path canonicalisation
Previous Next
Reported by: Mattias Andrée <maandree <at> kth.se>
Date: Sat, 1 Dec 2018 20:06:02 UTC
Severity: normal
Tags: notabug
Done: Stefan Kangas <stefan <at> marxist.se>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 33564 in the body.
You can then email your comments to 33564 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33564
; Package
emacs
.
(Sat, 01 Dec 2018 20:06:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Mattias Andrée <maandree <at> kth.se>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sat, 01 Dec 2018 20:06:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Emacs 26.1 removes ..'s incorrectly from file names.
Emacs removes the directory in front the .. rather than
getting its parent directory.
Example:
cd
mkdir -p 1/2
cd 1/2
echo 3 > ../../3
ln -s ~ 4
echo 5 > 5
emacs 4/../5 # works, but shouldn't
emacs 4/../$USER/3 # does not works, should
On Linux, the proper way to get the canonical path
for a file with the file descriptor $fd:
stat(3) /dev/fd/$fd
p := readlink(3) /dev/fd/$fd
if (st_nlinks != 0) {
stat(3) /dev/fd/$fd
if (st_nlinks == 0) {
p := readlink(3) /dev/fd/$fd
remove " (deleted)" from the end of p
}
} else {
remove " (deleted)" from the end of p
}
canonical path is p
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33564
; Package
emacs
.
(Sat, 01 Dec 2018 20:28:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 33564 <at> debbugs.gnu.org (full text, mbox):
On Dez 01 2018, Mattias Andrée <maandree <at> kth.se> wrote:
> Emacs 26.1 removes ..'s incorrectly from file names.
> Emacs removes the directory in front the .. rather than
> getting its parent directory.
This is deliberate. Emacs never consults the filesystem when
canonicalizing filenames, as documented in expand-file-name. This is
consistent with the logical view of the filesystem, and how the shell
builtin cd handles it.
Andreas.
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33564
; Package
emacs
.
(Sat, 01 Dec 2018 20:32:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 33564 <at> debbugs.gnu.org (full text, mbox):
tags 33564 notabug
thanks
> Date: Sat, 1 Dec 2018 21:04:50 +0100
> From: Mattias Andrée <maandree <at> kth.se>
>
> cd
> mkdir -p 1/2
> cd 1/2
> echo 3 > ../../3
> ln -s ~ 4
> echo 5 > 5
> emacs 4/../5 # works, but shouldn't
> emacs 4/../$USER/3 # does not works, should
This is by design: expand-file-name doesn't follow symlinks. It's
documented not to do that: see the doc string and the ELisp manual.
> On Linux, the proper way to get the canonical path
> for a file with the file descriptor $fd:
expand-file-name doesn't aim at yielding the canonical file name in
that sense.
Added tag(s) notabug.
Request was from
Eli Zaretskii <eliz <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Sat, 01 Dec 2018 20:32:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33564
; Package
emacs
.
(Sat, 01 Dec 2018 20:36:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 33564 <at> debbugs.gnu.org (full text, mbox):
On Sat, 1 Dec 2018 21:27:27 +0100
Andreas Schwab <schwab <at> linux-m68k.org> wrote:
> On Dez 01 2018, Mattias Andrée <maandree <at> kth.se> wrote:
>
> > Emacs 26.1 removes ..'s incorrectly from file names.
> > Emacs removes the directory in front the .. rather than
> > getting its parent directory.
>
> This is deliberate. Emacs never consults the filesystem when
> canonicalizing filenames, as documented in expand-file-name. This is
> consistent with the logical view of the filesystem, and how the shell
> builtin cd handles it.
What is the rationale for this? No other program Bash and Emacs
behave this way, including the coreutils.
It seems odd that the Bash suggest file from the wrong directory
so that even the coreutils cannot find them, only Emacs.
>
> Andreas.
>
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33564
; Package
emacs
.
(Sat, 01 Dec 2018 20:56:01 GMT)
Full text and
rfc822 format available.
Message #19 received at 33564 <at> debbugs.gnu.org (full text, mbox):
On Dez 01 2018, Mattias Andrée <maandree <at> kth.se> wrote:
> On Sat, 1 Dec 2018 21:27:27 +0100
> Andreas Schwab <schwab <at> linux-m68k.org> wrote:
>
>> On Dez 01 2018, Mattias Andrée <maandree <at> kth.se> wrote:
>>
>> > Emacs 26.1 removes ..'s incorrectly from file names.
>> > Emacs removes the directory in front the .. rather than
>> > getting its parent directory.
>>
>> This is deliberate. Emacs never consults the filesystem when
>> canonicalizing filenames, as documented in expand-file-name. This is
>> consistent with the logical view of the filesystem, and how the shell
>> builtin cd handles it.
>
> What is the rationale for this?
Canonicalizing is a pure textual operation.
> No other program Bash and Emacs behave this way, including the
> coreutils.
This is not true, as I explained above.
Andreas.
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33564
; Package
emacs
.
(Sat, 01 Dec 2018 21:15:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 33564 <at> debbugs.gnu.org (full text, mbox):
On Sat, 1 Dec 2018 21:55:29 +0100
Andreas Schwab <schwab <at> linux-m68k.org> wrote:
> On Dez 01 2018, Mattias Andrée <maandree <at> kth.se> wrote:
>
> > On Sat, 1 Dec 2018 21:27:27 +0100
> > Andreas Schwab <schwab <at> linux-m68k.org> wrote:
> >
> >> On Dez 01 2018, Mattias Andrée <maandree <at> kth.se> wrote:
> >>
> >> > Emacs 26.1 removes ..'s incorrectly from file names.
> >> > Emacs removes the directory in front the .. rather than
> >> > getting its parent directory.
> >>
> >> This is deliberate. Emacs never consults the filesystem when
> >> canonicalizing filenames, as documented in expand-file-name. This is
> >> consistent with the logical view of the filesystem, and how the shell
> >> builtin cd handles it.
> >
> > What is the rationale for this?
>
> Canonicalizing is a pure textual operation.
Yes, you said, but why should Emacs canonicalise the file names
given in the command line in the first place? One would expect
that if you examine a file with for example stat or cat, you
with be working with that file with you give Emacs the same
file name.
>
> > No other program Bash and Emacs behave this way, including the
> > coreutils.
>
> This is not true, as I explained above.
Okay, dash also behaves this way, but ls, cat, and nano, for example
don't (and no, you didn't explain, nor should you have, you should
have given counter examples, preferably GNU program). I don't know any
other program that behaves this way. The same think goes for resolving
~, normal programs use the file names given in the command line as is.
>
> Andreas.
>
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#33564
; Package
emacs
.
(Sun, 02 Dec 2018 06:28:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 33564 <at> debbugs.gnu.org (full text, mbox):
> Date: Sat, 1 Dec 2018 22:14:30 +0100
> From: Mattias Andrée <maandree <at> kth.se>
> Cc: 33564 <at> debbugs.gnu.org
>
> why should Emacs canonicalise the file names given in the command
> line in the first place?
One reason is so that it could meaningfully compare file names as
strings. Another reason is that relative file names change their
meaning when you switch buffers, because Emacs behaves in a way that
switching buffers conceptually changes your working directory to the
directory of that buffer.
Reply sent
to
Stefan Kangas <stefan <at> marxist.se>
:
You have taken responsibility.
(Wed, 21 Aug 2019 02:28:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Mattias Andrée <maandree <at> kth.se>
:
bug acknowledged by developer.
(Wed, 21 Aug 2019 02:28:03 GMT)
Full text and
rfc822 format available.
Message #30 received at 33564-done <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
> tags 33564 notabug
> thanks
>
>> Date: Sat, 1 Dec 2018 21:04:50 +0100
>> From: Mattias Andrée <maandree <at> kth.se>
>>
>> cd
>> mkdir -p 1/2
>> cd 1/2
>> echo 3 > ../../3
>> ln -s ~ 4
>> echo 5 > 5
>> emacs 4/../5 # works, but shouldn't
>> emacs 4/../$USER/3 # does not works, should
>
> This is by design: expand-file-name doesn't follow symlinks. It's
> documented not to do that: see the doc string and the ELisp manual.
>
>> On Linux, the proper way to get the canonical path
>> for a file with the file descriptor $fd:
>
> expand-file-name doesn't aim at yielding the canonical file name in
> that sense.
This was tagged notabug in December 2018; I'm now also closing this bug report.
Thanks,
Stefan Kangas
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 18 Sep 2019 11:24:10 GMT)
Full text and
rfc822 format available.
This bug report was last modified 4 years and 218 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.