Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Is it possible to clear empty :-tied elements?
- X-seq: zsh-users 27908
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Is it possible to clear empty :-tied elements?
- Date: Wed, 20 Jul 2022 15:32:27 -0400
- Archived-at: <https://zsh.org/users/27908>
- In-reply-to: <CAKc7PVAbCrSRNZtQ_b3ZX3iBOe9tjNdFX8bV1BMKSb7Wxj=mZQ@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- Openpgp: url=https://www.security.spodhuis.org/PGP/keys/keys-2013rsa-2020cv25519.asc
- References: <CAKc7PVAbCrSRNZtQ_b3ZX3iBOe9tjNdFX8bV1BMKSb7Wxj=mZQ@mail.gmail.com>
On 2022-07-19 at 21:54 +0200, Sebastian Gniazdowski wrote:
> export -UT CMAKE_PREFIX_PATH="$ZPFX:$CMAKE_PREFIX_PATH" cmake_prefix_path
>
> The problem is that the variable/array will contain empty element if the
> variable is empty when export is run.
>
> I wonder if is it possible to somehow clear such empty entry (i.e.: to
> remove :: from "a::b") without another line of code?
Assign it as an array and do _not_ quote the $ZPFX, so that empty values
are not preserved.
export -UT CMAKE_PREFIX_PATH cmake_prefix_path=($ZPFX "${(s,:,)CMAKE_PREFIX_PATH}")
If you have to be resilient to SH_WORD_SPLIT being enabled, then replace
$ZPFX with ${==ZPFX} instead.
-Phil
Messages sorted by:
Reverse Date,
Date,
Thread,
Author