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

Re: [PATCH] handle options of _arguments correctly

On Sep 29,  1:55am, Jun T. wrote:
} This is because, at line 18 of _arguments, $tmpargv is set to '-s',
} which is used at line 144 to remove -s from $lopts; i.e., -s is
} considered as an optspec, not an option to _arguments itself.
} A simple fix would be to move the while loop (lines 295-306) to the top
} of _arguments.
} This leads to the following patch. Are there any unexpected side
} effects of this?

I don't see anything immediate (though this renders the name "singsub"
for the array somewhat nonsensical).

The stuff on line 144 came from this change:

+2000-08-02  Sven Wischnowsky  <wischnow@xxxxxxx>
+       * 12475: Completion/Base/_arguments: prefer user-defined specs
+       over ones derived from --help output

I'm guessing that code should have looked for a ":" in $tmpargv and only
treat as specs, those positions that follow either the ":" or that follow
any option letter that can't appear to the left of a ":".  I haven't run
it down to this level, but it's possible that code pre-dates _arguments
having any switches of its own.


    _arguments -s -w -q -s --
    _arguments -s -w : -q -s --

are equivalent becaue of the -q (even though I'd hope no one wrote the
former in an actual completion function).  Which I think is what your
patch accomplishes (the -s and -w would be gobbled up and then the loop
ends at either the ":" or the -q whichever comes first).

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