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

Re: file completion of ~user/... stats wrong directory



>>>>> On July 10, 2009 Peter Stephenson <pws@xxxxxxx> wrote:

> Certainly sounds plausible.  It's odd this isn't an ever worse problem,
> but _path_files has so many possibilities it's surprisingly hard to
> trigger particular problems.

Looks like this is being caused by the 'accept-exact-dirs' logic in
_path_files:

|  if zstyle -t ":completion:${curcontext}:paths" accept-exact-dirs &&
|    [[ $pre = (#b)(*)/([^/]#) ]]; then
|    # We've been told that we can accept an exact directory
|    # prefix immediately.  Try this with the longest path prefix
|    # first:  this saves stats in the simple case and may get around
|    # automount behaviour if early components don't yet exist.
|    tmp1=$match[1]
|    tpre=$match[2]
|    while true; do
|      if [[ -d $donepath$tmp1 ]]; then
|        donepath=$donepath$tmp1/
|        pre=$tpre
|        break
|      elif [[ $tmp1 = (#b)(*)/([^/]#) ]]; then
|        tmp1=$match[1]
|        tpre=$match[2]/$tpre
|      else
|        break
|      fi
|    done
|  fi

When completing something of the form ~user/foo or $bar/foo, the test
[[ -d $donepath$tmp1 ]] is stat'ing the path 'foo' relative to the
current directory rather than with the stripped off prefix re-added.

greg



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