From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 8666 invoked from network); 2 Nov 2020 12:23:53 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 2 Nov 2020 12:23:53 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1604319833; b=RtBM/VwvrktQVVxSEp+ZBfsk5vr0bTR4d+lNJ1OpSsADpBmG2jCz/iTuMV4pz8Yvu+jPneCUJE f+Sp3abP0EaDFJ7Q6OfRwAFs8N3qgEv/AlrwEES1T52HSIuEsGarDJ9dvfPLifJZDnhSfpKn3o IxyLeebP4fsQbGgGugRhu6H2VHwv/veCryD6GWMgqtoo/hXWlLMrxa9xrpSYH7Q6mks28Awfj1 U3FlQ3SPU+vCnZ2TwROldGaccbgQtXL3mLDvrkLxqz26TSP8CnD2DgR7BQ5PNbI1hZ1GxXjxZN L3LO4qJhLOyZCmsRR+xSnKens2MvVm5J8xYp3ziWjW6ipw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f48.google.com) smtp.remote-ip=209.85.208.48; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1604319833; bh=KSO4dnWbtw3/yFVo+/jLJFkAyLn3NQ5GWvzUFfMXugk=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=w8dkCj8wW1w7rWf3BFEkVWodMPt87loPYFkryaB44QQzv+OqbBUCwe2zJMMKg+bdpPZwdHrESN et+yULfzkP/xRTluAVXNo4SQ8D9C5HE1lzmgBmJ4u/bIF7gDq3aDWIxml7KaKSfBKiBI8TJBVT 6erEygFm4OJFe6q0PWg+YZY7ttbAx2zmn7ajR+S9ODop6m1u6bc8iQxF6qMj+EPdMw5l5J2Kjh a1KXYkEfmZL8S82cLtC/DVrPH4aguGIjUu0po8DwKyzY8A4NnLrmF7Wmol/IkK964678ZsvBWQ bcFdiViIxhYzPHbqotmc5yNgX7Go42BqoVBHX+m/ViKgnQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=gprQOzH2tPdnTemioM3WnTik/HH+eVi4rRqefG7xgBQ=; b=bw9i4JMIuysEiJlw/pWLlgLQqH AiLxSKNu39HtycTPyXcJn4RcCVWigdEc8YmF4BarH19oHZ1ms1qN3x5/5xPAaqQNQwWxp5778SUXq h3yOxf6UWjXJVDjzfyi1UuMiQ/leqpnt8QIsMrfJMbvSAy8AjScxtEJ5yby6vZECRU8pWnzxek771 R1hfzaFzlrAAHP10zJda2bAWrYrQaMSkQsY8bA8LpCxeNwsWEqWCl1hOV5Bvj6wLm24+rGgA8718v mBWTITukGM8IYnriui3XaMKUASiZrYnf1AiYl0Lap0HMHG9IFAOtvylINFN4VC26pQhBW7HRR6sEw gt0zlYuw==; Received: from authenticated user by zero.zsh.org with local id 1kZYsH-000EEG-14; Mon, 02 Nov 2020 12:23:49 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f48.google.com) smtp.remote-ip=209.85.208.48; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ed1-f48.google.com ([209.85.208.48]:41575) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kZYrm-000DrX-GN; Mon, 02 Nov 2020 12:23:19 +0000 Received: by mail-ed1-f48.google.com with SMTP id l24so14128339edj.8 for ; Mon, 02 Nov 2020 04:23:18 -0800 (PST) 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 :cc; bh=gprQOzH2tPdnTemioM3WnTik/HH+eVi4rRqefG7xgBQ=; b=l9X5GTPttTcX0XiFbflwfRBMHIbCg0soVSJVUGGO4avE/5XD7y9RKlKYnHk1zUA3+B 0hp/nrY5AjXIlWWYTVJ1+AmFCNcxiMCHnMVf1gCzwh9NkuLpM5J8X4vlj2U8oEg2ZJi6 +EOCLhLt4jGg0M6doZrykrBIoZar3TaThJBnBEKnJZ51rqrq7/FF+e+xbbWBIKy/GjcV dv7Jg57CjkUFmUzwHqFzAMCZXB3TFwUo/FnlNfpgp9Jl1jdYFtNJhCbeAw926ioOOWQO jjzaIqeao3W4aCw4e5uitU/vqKMP1nlZS2jNKJVMxsaCQKWmgHONF90QKFsg7v2MrHWD AmYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gprQOzH2tPdnTemioM3WnTik/HH+eVi4rRqefG7xgBQ=; b=C8NZFlX63N5aVwQI2CgJ9negpRD78CMplra3g5njTnjb/B3hbyfpkbHy0ue4mMjwZr hZ+BPLGvxvxcu9FduaxMs+ZazgqJtryk0Eb+vw5tplsq45cU5dQYIeO8ehqIWbYzPzMe 9jAWEFN6o5a3q2aEbNksCmawYk/975lHYUKlxMXQaBAQUPCY6knhplDKZpWgrC8WeHnb wh9Vhhd9lifRUnAjhd0LTx6lq76lciLQNjsUmwKrUMg+Is55soXigWVZCRAXkY9wcP4t qz4inHRfRT+T11+xZFPk5yiuLC7/6ExsJNWqpaMY3oASZmjXbv+cl/5piWE64/4UK3xO izaQ== X-Gm-Message-State: AOAM531X4M0LABRiRJXgb+avRNbBgdvh3+27P9eQ+GJ/+KM7/vM9TvVW M5fy2vmelPA5/KToL+HVftSD6kpoEfPkqeB63bg= X-Google-Smtp-Source: ABdhPJxa4ZAz16OdaoimxZbgqvRJ/MDHTdlj9WmJTKaXj1sprnY6ERoouw2JA8Q+y15AP5OHLwMg+OoZMzWyyuLIYws= X-Received: by 2002:a05:6402:b72:: with SMTP id cb18mr15788386edb.129.1604319797900; Mon, 02 Nov 2020 04:23:17 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: =?UTF-8?B?UGV0ZXIgU2zDrcW+aWs=?= Date: Mon, 2 Nov 2020 13:23:01 +0100 Message-ID: Subject: Re: Removing an element from an array To: Roman Perepelitsa Cc: Zsh Users Content-Type: multipart/alternative; boundary="000000000000a8fef005b31ecfd9" X-Seq: 26145 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: --000000000000a8fef005b31ecfd9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 =D0=BF=D0=BE=D0=BD, 2. =D0=BD=D0=BE=D0=B2 2020. =D1=83 12:25 Roman Perepeli= tsa =D1=98=D0=B5 =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BE/=D0=BB=D0=B0: > On Mon, Nov 2, 2020 at 12:11 PM Peter Sl=C3=AD=C5=BEik > 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:|exc= l} > syntax. > > > > Here is my code: > > > > excl=3D($path_to_remove) > > export path=3D${path:|excl} > > This is pretty close. Here's the correct syntax: > > excl=3D($path_to_remove) > path=3D(${path:|excl}) > > However, if you want to remove just one element, there is a simpler way: > > path=3D(${path:#$path_to_remove}) > > Roman. > --000000000000a8fef005b31ecfd9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Dear Roman,

thank you for bo= th suggestions.

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

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

Thank you,
Pe= ter

=D0=BF=D0=BE=D0=BD, 2. =D0=BD=D0=BE=D0=B2 2020. =D1=83 12:25 R= oman Perepelitsa <roman.p= erepelitsa@gmail.com> =D1=98=D0=B5 =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0= =B0=D0=BE/=D0=BB=D0=B0:
On Mon, Nov 2, 2020 at 12:11 PM Peter Sl=C3=AD=C5=BEik <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=3D($path_to_remove)
> export path=3D${path:|excl}

This is pretty close. Here's the correct syntax:

=C2=A0 =C2=A0 excl=3D($path_to_remove)
=C2=A0 =C2=A0 path=3D(${path:|excl})

However, if you want to remove just one element, there is a simpler way:
=C2=A0 =C2=A0 path=3D(${path:#$path_to_remove})

Roman.
--000000000000a8fef005b31ecfd9--