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

_arguments bugs / _typeset (was Re: rsync --progress stops completion)



On Sep 19,  5:22am, Mikael Magnusson wrote:
}
} If we're collecting _arguments bugs here, I noticed yesterday that while
} typeset -<tab>
} correctly completes options, typing something after and then going
} back to the dash to complete, eg
} typeset -<tab> foo is written here
} just inserts a = sign.

Here's the doc for _arguments:

          With -A, no options will be completed after the first
          non-option argument on the line.  The -A must be followed by
          a pattern matching all strings which are not to be taken as
          arguments.  For example, to make _arguments stop completing
          options after the first normal argument, but ignoring all
          strings starting with a hyphen even if they are not described
          by one of the OPTSPECs, the form is `-A "-*"'.

While the statement "ignoring all strings starting with a hyphen" is
strictly correct, in practice you may want '-A "-?##"' or in even
'-A "-[^-]*"' to avoid considering a "-" by itself as an option.

If _typeset is changed to use '-A "-?##"' then 'typeset -<TAB> foo'
works, but I think it works for the wrong reason, two bugs canceling
each other out.  What happens is that ca_parse_line() fails to match
'-' with '-?##' and so does not ignore it, which allows it to find
that it might match an option spec.  With '-A "-*"' it ignores '-'
and incorrectly goes on to find the "rest of arguments" spec and to
apply that to the current word, even though the current word appears
before the non-option arguments begin.

This is all happening in the block of ca_parse_line() that has the
comment beginning "Bart 2009/11/17:".  I suspect the assignment to
state.def is too aggressive, but any obvious fiddling with it breaks
tests in Y03.



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