zsh-users
 help / color / mirror / code / Atom feed
From: "Jesper Nygårds" <jesper.nygards@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: Filtering array on index
Date: Fri, 26 Oct 2018 09:59:42 +0200	[thread overview]
Message-ID: <CABZhJg9_cJrWbsTJfiqTQy6mg6H5jdwAg7SORf-pCASwM2iZVA@mail.gmail.com> (raw)
In-Reply-To: <CABZhJg_fjE54nNUnoX0Bp1kH9wnCpor03kPxY=8dxHB8qsFhpQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1438 bytes --]

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@gmail.com>
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.
>

  reply	other threads:[~2018-10-26  8:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-25 11:29 Jesper Nygårds
2018-10-25 18:17 ` Mikael Magnusson
2018-10-25 18:55   ` Jesper Nygårds
2018-10-25 19:42   ` Daniel Shahaf
2018-10-25 20:21 ` Bart Schaefer
2018-10-25 20:42   ` dana
2018-10-26  4:14     ` Jesper Nygårds
2018-10-26  7:59       ` Jesper Nygårds [this message]
2018-10-26  8:21         ` dana
2018-10-26  9:28           ` Jesper Nygårds
2018-10-28  2:45           ` Bart Schaefer
2019-07-23  3:38 ` Sebastian Gniazdowski
2019-07-23  7:42   ` Sebastian Gniazdowski
2019-07-23  8:03     ` Sebastian Gniazdowski
2019-09-08  8:59     ` Sebastian Gniazdowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABZhJg9_cJrWbsTJfiqTQy6mg6H5jdwAg7SORf-pCASwM2iZVA@mail.gmail.com \
    --to=jesper.nygards@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).