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

Re: [(I)-foo] subscripting in _git

On 21 July 2011 13:21, Nikolai Weibull <now@xxxxxxxx> wrote:
> On Thu, Jul 21, 2011 at 12:32, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>> I noticed while looking at _git-add that _git does a lot of this type of thing:
>> if (( words[(I)-n|--dry-run] )); then
>> that particular example is fine, but further down is this
>> if [[ -n ${line[(I)-f|--force]} ]]; then
>> which seems to have two problems, first it uses line instead of words,
>> so it never matches.
> If you check out the latest revision, however, this has been fixed.  I
> fixed it an hour or so ago.  The correct pattern when checking for an
> option processed by _arguments is if [[ -n ${opt_args[(I)-o|--option]}
> ]]; then …; fi.
> There are, based on my checks, no other instances of the incorrect pattern.

You left out this part of my mail:
> Second it uses [[ -n ]] which will always be true as (I) returns a
> 0 when it didn't match.

The obvious part that I was missing is that opt_args is an associative
array, which changes the meaning of (I). :)

Mikael Magnusson

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