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

Re: Problem with _cd return code



Andrej Borsenkow wrote:

> ... when completing directory stack (cd -TAB). It completes it alright, but it
> always beeps; and sometimes I get additionally external directories listed.
> 
> It looks like return code problem, but I could not figure out how to fix it. I
> do not quite understand, what _wanted, _requested etc are supposed to return.

The same as all completion functions, of course: zero if matches were
added, non-zero otherwise.

What's happening is quite easy to see in _cd. That calls _popd for the 
directory stack like this:

  elif _popd || [[ $PREFIX != (\~|/|./|../)* && $#cdpath -ne 0 ]]; then

So, if _popd succeeds (adds matches), we go on completing, forgetting
about the zero-return from _popd and instead using the return value of 
one of the calls to _wanted or the return value from _alternative as
the result of _cd.

We should probably change that to something like:

  else
    _popd && ret=0
    if [[ $PREFIX != (\~|/|./|../)* && $#cdpath -ne 0 ]]; then
      ...
    else
      ...
    fi
    return ret
  fi

Unless I'm missing something that was intended by whoever wrote that.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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