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

Re: _files: -/ causes caller's _alternative to be disregarded

On Sep 2,  4:32am, Daniel Shahaf wrote:
} What I'm not clear about is why the invalid pattern for the
} "globbed-files" tag caused the "y:y:_hosts" alternative to be skipped.

The bad pattern causes _path_files to abort at line 468:

    tmp1=( $~tmp1 ) 2> /dev/null

This bails out all the way back to _dispatch line 63:

  eval "$comp" && ret=0

But _path_files has already done at least one "compadd" by that time, and
in fact the aborted part isn't going to do anything except unwind the
loop and return success, so you get the files completed but nothing
else.  However, the completer will have appeared to fail (returns non-
zero even though compadd was called) so another downstream completer
might get tried that ideally shouldn't be.  That's too late for the
_alternative part, though.

Good catch, though normally _path_files attempts to fix up glob quals
to avoid this.  However, doesn't (#q-/)(#q^-/) end up matching nothing?
(I think that's WHY the aborted portion is inconsequential.)  Is that
really what is intended here?

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