From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-users-return-23718-ml=inbox.vuxu.org@zsh.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 5ce03be5 for ; Thu, 25 Oct 2018 11:29:37 +0000 (UTC) Received: (qmail 11417 invoked by alias); 25 Oct 2018 11:29:20 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23718 Received: (qmail 25568 invoked by uid 1010); 25 Oct 2018 11:29:19 -0000 X-Qmail-Scanner-Diagnostics: from mail-lj1-f173.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.208.173):SA:0(-1.9/5.0):. Processed in 1.728731 secs); 25 Oct 2018 11:29:19 -0000 X-Envelope-From: jesper.nygards@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=Qfk8DU7G/m1zKRglQ423byy51lSqhFns1wLcV5VltRA=; b=uj1xXEzyrFKKpsHCiXD1ksWhbA/HgTIvqamtE+PNsFpTGTY/Voxm0n79No1XhrkgB8 R9QUsh5pIFoq0MfrY/XuAe7WhfpMoLyF/0kxWLMs3Svw76qXRSdOxDuGEFdbJHULQrDE x4ezbMeRL3aEDBOiwlHVgOYuznj27czrqkA5W6QGiqK7ae0E3jUty9oNFD7TIWycCgq5 aXmt5ZFduFqxdIaJzzuJUuiq0CI9otlTHay6NOuqfKkQhrKzBE4b+OSIIGU+Y7ARimFQ b6LtRLZbCVYcmQ2L2Plb2yTFOirrSKlJdLnLAAXcu6yt2m1rikhYLkB2rF2qGwvMDJUt OY/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Qfk8DU7G/m1zKRglQ423byy51lSqhFns1wLcV5VltRA=; b=ul/pU8mtFhj4npCDEjGbAD1P/dW8Xg8mHvGn//oYAgFzRYR4DoeOLe9c43b2rLffAu XpbIJvY+vZIxbt25xAz2WQTHpHxi698WoAQ4UxI3sJRJJYi5Xnr80Z9zgqEOfNgOBdK3 r4jwOpEm/xBsiLf/l4fLBLDIcjj5iZGsM7r8Jcfh8h61cZmSKkpghmjRYCJ3kw0ndW+l a1rsjMYtVsIeX0X96RHpJ1RtDv2fRthxOMulBYWIWKP6GxohBBXJs+OHNp4aFlpCrODo HUov+N74VmlPgAmqlIl5DfTbMbJubzgNrL80Md9SH/B9lpp87FBI5jVDl/64Yivvd+Fa 5h8A== X-Gm-Message-State: AGRZ1gJHWHjdOrKlEEy/CTStcpzhuPMHhinMepyfVUu/pKY2b+jijUXa 8J0L5U0T0+XQ/KANUgmHFi6FAz0f9zol+jz1S+K1rEW4 X-Google-Smtp-Source: AJdET5elTiYBQd0lJFqlaukv0lSw8vtNKoap6778c+R6Yd9G087z0jzTZ22X57PYI+Edt5ghZV7MVCM1jIU3JWjH3ek= X-Received: by 2002:a2e:7408:: with SMTP id p8-v6mr1043973ljc.101.1540466952548; Thu, 25 Oct 2018 04:29:12 -0700 (PDT) MIME-Version: 1.0 From: =?UTF-8?Q?Jesper_Nyg=C3=A5rds?= Date: Thu, 25 Oct 2018 13:29:01 +0200 Message-ID: Subject: Filtering array on index To: Zsh Users Content-Type: multipart/alternative; boundary="0000000000007eb3f405790be9a8" --0000000000007eb3f405790be9a8 Content-Type: text/plain; charset="UTF-8" I have an array which is the result of using zparseopts on a specification that makes it possible to specify several filters with a -v flag. The resulting array might look like the following: myarr=(-v filter1 -v filter2) I want to get rid of the "-v" elements, but only when they are the flag, and not the argument. In other words, I would the like the array (-v filter1 -v -v) to result in (filter1 -v). I had previously used: ${myarr:#-v}} which worked well, as I could accept the fact that -v was not possible to use as the option argument. However, now I need to make sure that a -v argument is preserved, and I thus need a compact way of specifying that I want to keep every other element in the array. The most compact way I have found is: for dash arg in $myarr; do myarr[(r)$dash]=() This works, but I was wondering if there's some more elegant solution, preferrably without using iteration? --0000000000007eb3f405790be9a8--