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

Re: bug 3.1.5 symlinks & cd



Phil Pennock wrote:

> 
> Typing away merrily, Bart Schaefer produced the immortal words:
> > On Nov 13,  9:19pm, Phil Pennock wrote:
> > } Using a stock zsh-3.1.5, there seems to be some problem with completion
> > } using one interpretation of a directory tree with symlinks, and cd using
> > } another.
> > 
> > This isn't new.  It behaves the same way in 3.0.5.  `setopt chaselinks'
> > will make the effect go away.
> 
> Yes, but:
>        CHASE_LINKS (-w)
>               Resolve symbolic links to their  true  values  when
>               changing directory.
> 
> The 'effect' only goes away insofar as this avoids the problem by never
> having a symbolic-link as part of PWD.
> 
> If you want to have the 'real' view of a layout, fine.  But forcing this
> option just to get a consistent interpretation of the FS dodges the fact
> that two different parts of the shell are taking differing approaches to
> symbolic-links pointing to directories.  Completion ignores the symbolic
> aspect of PWD, such that a ../ always uses the underlying 'true' layout,
> whilst cd handles the symbolic links.  This is a conflict that's
> entirely due to two parts of zsh doing things very differently.

I agree that this is a ugliness. But (as I already wrote) the only way 
I see to fix this cleanly is to add yet another option for compctl to
make -f, -g, and -/ use CHASELINKS. On the other hand, this is a bit
of an overkill considering that this would be useful only for cd and
the like.
A (partial) solution is to use a shell function, like this:

  compctl -K cdcomp -S/ -q cd pushd

  cdcomp() {
        local d r
        if [[ "$1" == */* ]]
        then
                d="${1%%/*}"
                r="${1#*/}"
                cd "$d" >& /dev/null
                reply=( ${r}*${2}(N-/) )
                reply=( $d/$reply )
                cd - >& /dev/null
        else
                reply=( ${1}*${2}(N-/) )
        fi
  }

So the question is: do you think that this is enough (probably with
some more work on the function) or should we build this into the shell?

Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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