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

Re: Filtering array on index



OK, one is never satisfied, as always. I have a continuation of this option
parsing business. And for the record, I realize I could solve this with a
loop, but it's always fun to see how far the impressive zsh functionality
can take one.

In addition to my filter option, I also have an override option which as it
name suggests is meant to be used as an override for the filters. In other
words, I want to remove the overrides from the list of filters. I'm looking
for a compact expression for this.

The following doesn't quite do what I want, since I can find no way of
specifying that I want the "-f" prefix removed from the elements in
$overrides, before its elements are then removed from the $filter list:

% filters=(); overrides=()
% set -- -v one -v two -f one
% zparseopts -D -E v+:-=filters f+:-=overrides
% print -lr -- ${${filters#-v}:|overrides}
one
two

(I wanted only "one" to be printed)

The documentation for ":|" explicitly says "arrayname is the name (N.B.,
not contents) of an array variable", so I can't do the usual trick of
nesting the operations. Is there a way to achieve this?


On Fri, Oct 26, 2018 at 6:14 AM Jesper Nygårds <jesper.nygards@xxxxxxxxx>
wrote:

> Thank you!
>
> The combination of Bart's and Dana's answers gives me the perfect solution
> for my problem. I had skipped over the documentation for "-" as part of the
> spec, thinking it was not relevant.
>


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