zsh-users
 help / color / mirror / code / Atom feed
From: "Peter Slížik" <peter.slizik@gmail.com>
To: Roman Perepelitsa <roman.perepelitsa@gmail.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Removing an element from an array
Date: Mon, 2 Nov 2020 13:23:01 +0100	[thread overview]
Message-ID: <CAC-uhUAPKg9LP-Tt-5bkQYR5n57m6L=EZzLhtKJ=q4hRB1qcYQ@mail.gmail.com> (raw)
In-Reply-To: <CAN=4vMoAcip8q_zTm1-R-81d15OP9o6_Gyu7cvcpdbE-BLScVg@mail.gmail.com>

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

Dear Roman,

thank you for both suggestions.

By the way,  can I ask why it is necessary to re-introduce the array
context by another pair of parentheses, if the expression already produces
an array value?

Or does the ${...:|...} expression produce a string which needs to be
parsed again? Would this cause problems if any of the path elements
contained a space in the file name?

Thank you,
Peter

пон, 2. нов 2020. у 12:25 Roman Perepelitsa <roman.perepelitsa@gmail.com>
је написао/ла:

> On Mon, Nov 2, 2020 at 12:11 PM Peter Slížik <peter.slizik@gmail.com>
> wrote:
> >
> > I would like to remove an element from an array - actually a path from
> the $path variable. After some googling, I've discovered the ${array:|excl}
> syntax.
> >
> > Here is my code:
> >
> > excl=($path_to_remove)
> > export path=${path:|excl}
>
> This is pretty close. Here's the correct syntax:
>
>     excl=($path_to_remove)
>     path=(${path:|excl})
>
> However, if you want to remove just one element, there is a simpler way:
>
>     path=(${path:#$path_to_remove})
>
> Roman.
>

[-- Attachment #2: Type: text/html, Size: 1646 bytes --]

  reply	other threads:[~2020-11-02 12:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-02 11:11 Peter Slížik
2020-11-02 11:25 ` Roman Perepelitsa
2020-11-02 12:23   ` Peter Slížik [this message]
2020-11-02 18:31     ` Bart Schaefer

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='CAC-uhUAPKg9LP-Tt-5bkQYR5n57m6L=EZzLhtKJ=q4hRB1qcYQ@mail.gmail.com' \
    --to=peter.slizik@gmail.com \
    --cc=roman.perepelitsa@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).