Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: bad cd completion for ../ (with CHASE_DOTS unset)



I'm having a serious case of deja-vu over this ... I'm sure I explained 
this before, and not that long ago, but I can't find the message anywhere.

On Mon, 30 Aug 2004, Vincent Lefevre wrote:

> Here, CHASE_DOTS isn't set, and my /home/lefevre/Mail directory contains 
> [a] symbolic link [...] if I try to do a completion with "cd ../[TAB]", 
> zsh gives the completions corresponding to the subdirectories of 
> /users/spaces/lefevre/Mail instead of the subdirectories of 
> /home/lefevre/Mail, though CHASE_DOTS isn't set. I think this is a bug.

The trouble is that completion uses globbing to find the possible matching 
files, and globbing always behaves the way "cd" does with CHASE_LINKS set.

You might think that the fix is as easy as deleting "parent/.." substrings 
and replacing a leading "../" with "$PWD:h/", but the way the completion 
code is structured makes that a tricky proposition ... I don't think there 
is any variable whose value can be changed in _cd that remains visible 
down in _path_files when it starts decomposing the path at slashes and 
examining each directory ... and even if there is, doing so would probably 
generate some strange completions.

That means the only "fix" is putting a fairly ugly special-case into 
_path_files that applies only to _cd, without breaking every other path 
completion in the world.  Sven W. is incommunicado and no one else has 
been brave enough to plunge into the jungle with a machete.

(I've always thought CHASE_LINKS ought to be the one and only behavior.)

A possible workaround is to insert another function into your completer 
style, which acts as an expander to do the above-mentioned replacements on
the current word.  Thus you'd have this sort of behavior:

zsh% cd ~/Mail/arc
zsh% cd ../<TAB>
zsh% cd ~/Mail/

That is, you'd have to press TAB once to get the expansion before you can
start completing.

> Please Cc to me (the Mail-Followup-To should be set correctly).

Chortle.  Quite a, shall we say, discussion about M-F-T is in progress on 
one of the IETF lists the last couple of days.



Messages sorted by: Reverse Date, Date, Thread, Author