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

Re: Filtering array on index



On 25 Oct 2018, at 15:21, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>% zparseopts -a vees v+::
>...
>% print -lr -- ${vees#-v}

That method is the one i've seen used to solve this problem in completion
functions. But you have to make sure to add - at the end of the option spec if
you want it to work with mandatory (single-colon) arguments:

>An optional argument is put into the same array element as the option name
>(note that this makes empty strings as arguments indistinguishable). A
>mandatory argument is added as a separate element unless the ‘:-’ form is used,
>in which case the argument is put into the same element.

So if the argument to -v is mandatory you'd just use v+:- as the spec

dana



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