Discussion:
Incorrect path canonicalisation at autocompletion
Mattias Andrée
2018-12-01 20:12:49 UTC
Permalink
Using Bash 4.4.023, type

cd
mkdir -p 1/2
cd 1/2
touch ../../3
ln -s ~ 4
touch 5
ls 4/../

without pressing enter at the last line,
instead press <tab> twice. 4/ and 5 will
be suggested, but if you press <enter>
you will see that it should suggest the
files in /home.
Chet Ramey
2018-12-03 14:33:48 UTC
Permalink
Post by Mattias Andrée
Using Bash 4.4.023, type
cd
mkdir -p 1/2
cd 1/2
touch ../../3
ln -s ~ 4
touch 5
ls 4/../
without pressing enter at the last line,
instead press <tab> twice. 4/ and 5 will
be suggested, but if you press <enter>
you will see that it should suggest the> files in /home.
It's not a bug. Bash maintains a logical view of the file system and the
current directory for cd, pwd, and $PWD, as Posix specifies. One of the
consequences is that the pathname of the current directory depends on the
path used to reach it, which affects how bash canonicalizes `..'. Bash is
consistent in its use of this logical view across shell features, which
includes completion.

If you want to see a physical view of the file system, use
`set -o physical'.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU ***@case.edu http://tiswww.cwru.edu/~chet/
Mattias Andrée
2018-12-03 14:49:08 UTC
Permalink
On Mon, 3 Dec 2018 09:33:48 -0500
Post by Chet Ramey
Post by Mattias Andrée
Using Bash 4.4.023, type
cd
mkdir -p 1/2
cd 1/2
touch ../../3
ln -s ~ 4
touch 5
ls 4/../
without pressing enter at the last line,
instead press <tab> twice. 4/ and 5 will
be suggested, but if you press <enter>
you will see that it should suggest the> files in /home.
It's not a bug. Bash maintains a logical view of the file system and the
current directory for cd, pwd, and $PWD, as Posix specifies. One of the
consequences is that the pathname of the current directory depends on the
path used to reach it, which affects how bash canonicalizes `..'. Bash is
consistent in its use of this logical view across shell features, which
includes completion.
If you want to see a physical view of the file system, use
`set -o physical'.
Is there a way to only get physical view for
completion but logical view for cd, pwd, and $PWD?
Chet Ramey
2018-12-03 14:58:33 UTC
Permalink
Post by Mattias Andrée
On Mon, 3 Dec 2018 09:33:48 -0500
Post by Chet Ramey
Post by Mattias Andrée
Using Bash 4.4.023, type
cd
mkdir -p 1/2
cd 1/2
touch ../../3
ln -s ~ 4
touch 5
ls 4/../
without pressing enter at the last line,
instead press <tab> twice. 4/ and 5 will
be suggested, but if you press <enter>
you will see that it should suggest the> files in /home.
It's not a bug. Bash maintains a logical view of the file system and the
current directory for cd, pwd, and $PWD, as Posix specifies. One of the
consequences is that the pathname of the current directory depends on the
path used to reach it, which affects how bash canonicalizes `..'. Bash is
consistent in its use of this logical view across shell features, which
includes completion.
If you want to see a physical view of the file system, use
`set -o physical'.
Is there a way to only get physical view for
completion but logical view for cd, pwd, and $PWD?
You can by using set -o physical within a completion function or running
with set -o physical all the time and using `cd -L' and `pwd -L'.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU ***@case.edu http://tiswww.cwru.edu/~chet/
Mattias Andrée
2018-12-03 15:05:56 UTC
Permalink
On Mon, 3 Dec 2018 09:58:33 -0500
Post by Chet Ramey
Post by Mattias Andrée
On Mon, 3 Dec 2018 09:33:48 -0500
Post by Chet Ramey
Post by Mattias Andrée
Using Bash 4.4.023, type
cd
mkdir -p 1/2
cd 1/2
touch ../../3
ln -s ~ 4
touch 5
ls 4/../
without pressing enter at the last line,
instead press <tab> twice. 4/ and 5 will
be suggested, but if you press <enter>
you will see that it should suggest the> files in /home.
It's not a bug. Bash maintains a logical view of the file system and the
current directory for cd, pwd, and $PWD, as Posix specifies. One of the
consequences is that the pathname of the current directory depends on the
path used to reach it, which affects how bash canonicalizes `..'. Bash is
consistent in its use of this logical view across shell features, which
includes completion.
If you want to see a physical view of the file system, use
`set -o physical'.
Is there a way to only get physical view for
completion but logical view for cd, pwd, and $PWD?
You can by using set -o physical within a completion function or running
with set -o physical all the time and using `cd -L' and `pwd -L'.
Thanks!

Loading...