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, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 18305 invoked from network); 10 Nov 2022 19:28:51 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 10 Nov 2022 19:28:51 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1668108531; b=nabI6vKreehewauSCqJttKl4YG8+/2g61APSTprdw6OfIt0MnaGaA3aO5555b2ujus0t/zfLe8 MaQzs3DGhtHMi5H/VD29qwudKoC6jDRtzrzc3cKpL8IFz/pw0Ns6sT0dqKMbimLi+4cVf5581v bD52akbwraAcMxVYo8RzPb92SBBuoUilE7zT5M1b1Vg5q/cE13hzde5eu55l54JPAnOGcsTST3 fXS4Er5dUdjoTum/cW5ZDN5tUHByrCMbdu7auXAYRfD0FfTr/eV0FZxNf9zplOZ3WKvydGL3B1 KWiwO7hvbAFOBXZ+3AUIpb5jZpfR8hvpfTgTw77ziTdjRg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta03.eastlink.ca) smtp.remote-ip=24.224.136.9; 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=1668108531; bh=4PN66yBiVWSEktaOLPdSS4TKRCLL3ARmsMUFG2+4jDg=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:DKIM-Signature; b=cEx0rJXG5f3DRBZWuecWUAkmOVwG0c1kGhHwExjzHutm+PaigsCO2vdtk6tEm9YHqx6W/thj0i +pM6YXfaEAzavws8TxZM1qVGWfroeAnCbjBZTuAq1W9/BEXJplLZyoeBtNGuBPr541Wal+NUkt Ni7XeTgknWfN/+alZBjnTs0XO1VpUjh8MlxdpBMNT0uq59DTTsh1wII/l5iWNQF3m8scFcl/x6 vMOlQM72oXr7yzTqPPElyGSeHAkGbABuw+ehoJQDiPtGBrpC5lFkC/ALLFrCngIH5+sh1YZ4Gp W/LHzs2Bmk9lgu6cSNhQfL2dJlztwuDQTI3X6EQHHXG2ng==; 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:Content-transfer-encoding: Content-type:In-reply-to:From:References:To:Subject:MIME-version:Date: Message-id:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=+C2A/Pwlqm5Wtf1rkdMzOsQ9UAywxl9sc7pN2tIwfBo=; b=G+80xUfuHU+KlyTQ4qAfwNst6B vA2gFjJ89FpYTtE3kA0KpGIKDehcpih8/euE/fJCuBwMA3w7R+WRiEyA7iPgeji7RtjneoNBL4bn9 911/Vw63T2WFiqybRElOWbPAWKuGkqk/RX1eE4efFoQWglDoM9NA6u4cbOWV47fhgFRma72gg5WFF 72eLUNCFSDf1+w01/BK5ocU4Np+Qwsz6zuiu1nHdstyyumqIRxjT8OgAM0RA08+WAWlhbYe3sO+No +75B7tUrv6MY5aXEctsTVDN5hh1A7LOhgGFkCiKy0KRkn7110HRlSrjhqElVN0wV2QD4IOQLd4HsG OZYSBS3w==; Received: by zero.zsh.org with local id 1otDEI-0006dA-Px; Thu, 10 Nov 2022 19:28:50 +0000 Authentication-Results: zsh.org; iprev=pass (mta03.eastlink.ca) smtp.remote-ip=24.224.136.9; dmarc=none header.from=eastlink.ca; arc=none Received: from mta03.eastlink.ca ([24.224.136.9]:49949) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1otDDa-0005uf-Uz; Thu, 10 Nov 2022 19:28:07 +0000 Received: from csp02.eastlink.ca ([71.7.199.167]) by mta03.eastlink.ca (Oracle Communications Messaging Server 8.0.2.2.20180531 64bit (built May 31 2018)) with ESMTPS id <0RL5007SOBITWB51@mta03.eastlink.ca> for zsh-users@zsh.org; Thu, 10 Nov 2022 15:28:05 -0400 (AST) Received: from [192.168.0.3] ([24.207.18.108]) by Eastlink with ESMTPSA id tDDZo39qogfyjtDDZocoKt; Thu, 10 Nov 2022 15:28:05 -0400 X-Authority-Analysis: v=2.4 cv=M9uLaQ8s c=1 sm=1 tr=0 ts=636d50c5 a=xN66ZtSbq5jdJYpBp7G/jQ==:117 a=xN66ZtSbq5jdJYpBp7G/jQ==:17 a=IkcTkHD0fZMA:10 a=M9hbNRUfyqTuCerCjqIA:9 a=QEXdDO2ut3YA:10 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrfeeggdduvdeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesthekredttdefjeenucfhrhhomheptfgrhicutehnughrvgifshcuoehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgeqnecuggftrfgrthhtvghrnhepiedtjeffvefgtdehgefgteekueeggeeitedutddvvdduteetffdvveelgfeukedunecukfhppedvgedrvddtjedrudekrddutdeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrddvtdejrddukedruddtkedphhgvlhhopegludelvddrudeikedrtddrfegnpdhmrghilhhfrhhomheprhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepreerpdhrtghpthhtohepiihshhdquhhsvghrshesiihshhdrohhrghdpghgvthdqkghiphfrrghsshifugepthhruhgv X-Vade-Score: 0 X-Vade-State: 0 X-EL-AUTH: rayandrews@eastlink.ca Message-id: <0a7dbe0d-1554-269a-f420-bfe320c7c838@eastlink.ca> Date: Thu, 10 Nov 2022 11:28:04 -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. Content-language: en-US To: zsh-users@zsh.org References: <549715c2-8b36-8b7e-e3ac-cac02f43dd0f@eastlink.ca> From: Ray Andrews In-reply-to: Content-type: text/plain; charset=UTF-8; format=flowed Content-transfer-encoding: 8bit X-Seq: 28361 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: On 2022-11-10 10:54, Bart Schaefer wrote: > >> cc[42]="foo bar" >> cc[42]=(foo bar) > The first one resets cc[42]. The second one both updates cc[42] and > inserts a new cc[43] after it. Now there's a surprise.  Nuts, that explains the weird output and the seemingly empty next element.  It bleeding creates a new empty next element!!  I'll leave it to more adept people to understand why that's ever wanted. Anyway, I stopped slicing (or did I start slicing? ...) anyway: cc[$aa]=( ${cc[$aa]/(#b)((#i)$filter)/$'\e['$color;1m${match[1]}$'\e[0m'} ) ... is the now slightly understandable strange output and ... cc[$aa]=${cc[$aa]/(#b)((#i)$filter)/$'\e['$color;1m${match[1]}$'\e[0m'} ...  works just fine :-)  I've gotten into the habit of always using the parentheses just because. > There is also the form > > cc[42,44]=(foo bar) > > which removes three elements (42,43,44) and replaces them with two new > ones (42 and 43). Hence a "slice". Sheesh.  So it looks like I stopped slicing.  But that just above is sorta understandable. BTW I'm not using Roman's '(#M)' syntax because it seems to want to print all sorts of values to the terminal.  Like '$MATCH' is some internal variable that always prints itself or something. One last issue, tinkering with the code even as I compose this: cc[$aa]=${cc[$aa]/(#b)(${zsh_case}${filter})/$'\e['$color;1m${match[1]}$'\e[0m'} ... the one thing left is to insert '$zsh_case' in there, which so far is not working.  But Roman has the answer: cc[$aa]=${cc[$aa]/(#b)($~zsh_case${filter})/$'\e['$color;1m${match[1]}$'\e[0m'} ... I have not idea what '$~' means, but it works. BTW, to my surprise, using native code gives the same performance as using grep, 40 seconds on a stress test here.  sed wanted 43 seconds.