bug-bash
[Top][All Lists]
Advanced

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

insert-completions and tab-completions do not handle symlinks correctly


From: Anton Koinov
Subject: insert-completions and tab-completions do not handle symlinks correctly
Date: Wed, 14 Jul 2004 01:27:40 -0400
User-agent: KMail/1.6.2

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H  -I.  -I. -I./include -I./lib  
-march=athlon-xp -O3 -pipe
uname output: Linux desk 2.6.5-gentoo-r1 #4 Tue May 18 20:09:12 EDT 2004 i686 
AMD Athlon(tm) XP 2100+ AuthenticAMD GNU/Linux
Machine Type: i686-pc-linux-gnu

Bash Version: 2.05b
Patch Level: 0
Release Status: release

Description:
insert-completions (Meta-*), tab-completions (Tab-Tab), and possibly other 
related functions do not handle symlinks correctly.

It appears that expanding completions for "/path/to/symlink/.." results in it 
being considered the same as "/path/to", instead of 
"/whatever-path-symlink-points-to/..".

Repeat-By:
In a bash shell session, execute:

mkdir a
mkdir a/k
mkdir a/l
mkdir a/k/x
mkdir a/k/y
cd a
ln -s k/y link-y
ls link-y/..

This will otput: x/ y/
That is, correctly link-y/.. == a/k

Now, start a new command and type: ls link-y/../<Meta-*> to invoke 
insert-completions
What you get is: ls link-y/../k link-y/../l link-y/../link-y
That is, insert-completions interprets link-y/.. == a, which is incorrect.
This seems to be happening, because .. (go up to parent directory) is applied 
before the symlink link-y is canonicalized. That is, the expansion of the 
path is:

link-y/.. == . (which in our case is 'a') <this is incorrect>
link-y/../* == ./*

Fix:
Must canonicalize (expand symlinks) for each individual sub-path before going 
to parent directory. In other words, in the above example the sequence of 
canonicalizations is:

link-y == k/y
link-y/.. == k

Thanks,
Anton




reply via email to

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