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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HTML_MESSAGE,MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13267 invoked from network); 14 Nov 2022 17:09:39 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 14 Nov 2022 17:09:39 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1668445779; b=J/c5QUzqDHoSHcwK5vgcgUaJaeRmwtiafnV7UjRjWr1wZ3WJHf+xNbG4Ymer150qu1jLKK5eS0 OnmeBMARQNvdqV509WlwP8ZKduv4w6jEjopjmzwMIGT+YKYYbeVSKXb5VeFIxeEMZBxfRzs0Bf lK3m8J4kHCqRuTLiOI74Bf/OSN66WcpwwPJ/6DibL2mR3GfcZbvRReS1LtNFXbG6I8vAfgjO5U 9irn+dXcLRBwDYoajjrP6xqeiaGJu5SOzFDjFwhUf1XUUxCnkYcqgYkqjPK6Q6Y0xohOJu1pop 1B0KhWjAiVfYwFtZrmq/TPW9+1HhNJBxbP0n1C8P7PLTag==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta02.eastlink.ca) smtp.remote-ip=24.224.136.13; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1668445779; bh=G4NicSFG+Qd+Bc8ANUBdxU1OPJwsfs9fvffIDRxVdHo=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:References:To:From:Subject:MIME-Version:Date: Message-ID:Content-Type:DKIM-Signature; b=PaZuSuzfETJDp03EMp94Nh/632D3kgjGz94hNG65QmSN0xihJVE27iP8YR+QpAX4jJRj2rWVpF ZVONvbxKQLoj/7hN2jtsjN8UoI+DLphixMg2mNB8NDzPLyAs0aOnH+ru3X03B7Zo42cF70a+cp i0I3QirCQX/6WRFWGkjbfa3A/CXpcdE3Ft20+/aopSsIdjkdPC6xi+T0xIFACpIEp/gXGnVkZs dkGfpkaBrvgPg6Koo0PuE+5bG5vfOHRvkr67+xyvD+s1Up30tq4QT4Ey8Y0ZzOY9EdNrOa9WfY s3n//GuZlTyY0tgfzPr1HX9jCn8Cvicc4dY9Iq4og//WWg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-reply-to:References:To:From: Subject:MIME-version:Date:Message-id:Content-type:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=B7OhyjBd23gz496FxXBKaXnPS3M9Ms/hsAPtyKC0i9k=; b=rVh1cSZGZSJAym9/Fq8/moEyV7 +ZBw88muH7AsOg9AtBzOlXUhdVs6OielN0S3A2eNatBNNO9EUzgFrR5OER14ivOAL824/9+Lb1L9Q EtvORm/s3E8CSt/T2r+N7khsvG4W1CbEVBrv4Oq2OCPehT7H0EWM+JGvbENmpzF/7jSucvPnnbbqK t17VytvTa+woDe5yEetlw579vi7YtbxONpKTylglHnNw3YbHyE7qxmbC27ZNoW2eY6H6k9QTytBUg qGWTmOwr2f4VTzd77fbrpscUGTSDym9bbmbo/H2jzkxb5Amk8KFRy++SHDd569vWhQSCnRohQJ4ra 4r2fblXQ==; Received: by zero.zsh.org with local id 1oucxl-0004r1-NN; Mon, 14 Nov 2022 17:09:37 +0000 Authentication-Results: zsh.org; iprev=pass (mta02.eastlink.ca) smtp.remote-ip=24.224.136.13; dmarc=none header.from=eastlink.ca; arc=none Received: from mta02.eastlink.ca ([24.224.136.13]:52138) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1oucwj-0004CG-5B; Mon, 14 Nov 2022 17:08:34 +0000 Received: from csp01.eastlink.ca ([71.7.199.166]) by mta02.eastlink.ca (Oracle Communications Messaging Server 8.0.2.2.20180531 64bit (built May 31 2018)) with ESMTPS id <0RLC00MBRFY2K570@mta02.eastlink.ca> for zsh-users@zsh.org; Mon, 14 Nov 2022 13:08:31 -0400 (AST) Received: from [192.168.0.3] ([24.207.18.108]) by Eastlink with ESMTPSA id ucwgo7JPjkffJucwhotxiH; Mon, 14 Nov 2022 13:08:31 -0400 X-Authority-Analysis: v=2.4 cv=Lbf6qBTi c=1 sm=1 tr=0 ts=6372760f a=xN66ZtSbq5jdJYpBp7G/jQ==:117 a=xN66ZtSbq5jdJYpBp7G/jQ==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=Ye9q-bpsAAAA:8 a=DVdS7W6a698rI3cY9IcA:9 a=QEXdDO2ut3YA:10 a=gir0-LH0AAAA:8 a=nW82JTSqXUcJDZf76YUA:9 a=416QkEyhzCBOX3PO:21 a=_W_S_7VecoQA:10 a=aLewGyoHDmJ4ULJHWpSz:22 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrgedvgdejtdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfgtefuvffnkffpmfdpqfgfvfenuceurghilhhouhhtmecufedttdenucenucfjughrpegtkfffgggfuffhvfhfjgesrgdtreertdefjeenucfhrhhomheptfgrhicutehnughrvgifshcuoehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgeqnecuggftrfgrthhtvghrnhepvdfggeehtddtheefkeelleeuvdehveeuheejgeetheeigfeuhfdvtdejledtgeeinecuffhomhgrihhnpehsthgrtghkvgigtghhrghnghgvrdgtohhmnecukfhppedvgedrvddtjedrudekrddutdeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrddvtdejrddukedruddtkedphhgvlhhopegludelvddrudeikedrtddrfegnpdhmrghilhhfrhhomheprhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepreerpdhrtghpthhtohepiihshhdquhhsvghrshesiihshhdrohhrghdpghgvthdqkghiphfrrghsshifugepthhruhgv X-Vade-Score: 0 X-Vade-State: 0 X-EL-AUTH: rayandrews@eastlink.ca Content-type: multipart/alternative; boundary="------------FuiYxyW6CTgJ0V3Tg3XjVYNc" Message-id: <77692192-70b3-8a6a-fd01-d5f8b37f59b2@eastlink.ca> Date: Mon, 14 Nov 2022 09:08:30 -0800 MIME-version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: coloring substitution seems to eat next line. From: Ray Andrews To: zsh-users@zsh.org References: <0a7dbe0d-1554-269a-f420-bfe320c7c838@eastlink.ca> <6d7ba212-be9d-6bb4-f5ce-9a796032ade0@eastlink.ca> <6a92000c-dee5-a1e3-a77f-6a4697a66ab1@eastlink.ca> <34a949c4-0853-4c65-d2ad-db40749dff81@eastlink.ca> <2dd50dc8-cdbc-02e0-0e1e-485718732d0d@eastlink.ca> <3a10f310-3ee8-d3b4-f6db-7fdb18b81b1f@eastlink.ca> Content-language: en-US In-reply-to: X-Seq: 28383 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: This is a multi-part message in MIME format. --------------FuiYxyW6CTgJ0V3Tg3XjVYNc Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2022-11-13 07:09, Ray Andrews wrote: > Roman: > >             cc=( ${(M)cc:#*$~zsh_case${filter}*} ) > > I've been applying that in some other functions but I need a variation > that will erase non-matching lines but leave them as blanks so that > array indexes do not change.  Reason being that a subsequent merge > with another array will happen and indexes must mesh.  I'm doing it > right now by using a dummy string as replacement for a non-match and > then combining the arrays and then deleting the dummies but that's > obviously clumsy. Stéphane Chazelas over at StackExchange offers this:         cc=( "${cc[@]/#%^*$~zsh_case${filter}*}" ) ... and it seems to do exactly what I want.  I understand the negation and the way the '[@]' and the outer quotes protect the length of the array, now I just need to understand the '#%' anchors -- but they are essential. > > > --------------FuiYxyW6CTgJ0V3Tg3XjVYNc Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 2022-11-13 07:09, Ray Andrews wrote:
Roman:

            cc=( ${(M)cc:#*$~zsh_case${filter}*} )

I've been applying that in some other functions but I need a variation that will erase non-matching lines but leave them as blanks so that array indexes do not change.  Reason being that a subsequent merge with another array will happen and indexes must mesh.  I'm doing it right now by using a dummy string as replacement for a non-match and then combining the arrays and then deleting the dummies but that's obviously clumsy.

Stéphane Chazelas over at StackExchange offers this:

        cc=( "${cc[@]/#%^*$~zsh_case${filter}*}" )

... and it seems to do exactly what I want.  I understand the negation and the way the '[@]' and the outer quotes protect the length of the array, now I just need to understand the '#%' anchors -- but they are essential.





--------------FuiYxyW6CTgJ0V3Tg3XjVYNc--