Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Filtering array on index
- X-seq: zsh-users 23725
- From: Jesper Nygårds <jesper.nygards@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Filtering array on index
- Date: Fri, 26 Oct 2018 09:59:42 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=/A0F8H+4YUeZ6ve74shsldlyLPQTpjrEfoievMlFmh0=; b=n/XWkdwxHZ5SEWp3OnGBhyYSfV48f9oHBSrft66DaD7qRRueakcfCFKjkrK7z/juHe tAveRv3LsZTcAC+Fd/pJDLOpA3vrgEz1JX9seYNrMXTjhF5ZYeYCPejs5tTLCQLMrrDJ f8R+I7OkKnTuSQxAql5mqi67EnHQvxUE9Dk5YtbtCrodISgBSANce67CObQSh6RpUHyb sA8zKnRp/tVgpcaUJkaoyRWbBZ3FG5G77qBN5NoMDn7K2wdGzWszJvpJNM9mmRJ3JVEY Gmj8TI+ZXoXcQZQ4SjFhvZofY7mLquFTcAbykOnbfeIz0u2DyvuZDzUu388HKj2fciZq O5eQ==
- In-reply-to: <CABZhJg_fjE54nNUnoX0Bp1kH9wnCpor03kPxY=8dxHB8qsFhpQ@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CABZhJg80vQuMHGKABkzR1bdtt89Akpkfd8kWOV83N-qvqioaXw@mail.gmail.com> <CAH+w=7ZtqnxZqvYrP0AqNRj5iLAND-YrMo3-ZN9Vzk_Ax4vKNA@mail.gmail.com> <63A34262-4216-4AFD-93B6-035CCEE44908@dana.is> <CABZhJg_fjE54nNUnoX0Bp1kH9wnCpor03kPxY=8dxHB8qsFhpQ@mail.gmail.com>
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