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,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 5666 invoked from network); 10 Nov 2022 21:53:05 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 10 Nov 2022 21:53:05 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1668117185; b=ES04795vf+BsY3VvNunt1kHOEDfSRjVy+GXa9Rj2kzuC4pDkx3RvC5gKjXFX5iOCR+PzzabVoN GgmNLy9IrmNT5UyAc6NTTEE1TA4s09dSOYVb0j4s1lX6ZYIIfy9BKNKDPDs82yGXq4rlgORG5k U9fwhzjrBcu1PZfpPgHG156CGDHZ1CWSJB6xZYL4NgUelRJl9htDP1JtPBjgdWf3q4gIUU4IET mpVbNe9zgAEjqf68YM33uLu/PdLUT9nO3JQ21/sU4YuoswFPafCOuI7bJ6SQ480rLaJcxNdU8p M3fT1xOJq5rBBixnjUTFpCQpNCjcRyUglkIRH9QlPjr+Vg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yb1-f178.google.com) smtp.remote-ip=209.85.219.178; dkim=pass header.d=gmail.com header.s=20210112 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-20210803; t=1668117185; bh=9WLDbvt1E5dXUYLBh7DQXowZIGLQuhQlI2ckuIztbv4=; 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=NO+XVIsLrIl3JL8U3csl/RnjNu1uodLp1hMq4sQnwIKLf7u33dr/OY4k0qq/HDrnQSKTRAsUGN yCjDRkd0rytO2l7aPr96h1WOsSPfnhqF/UB8+lwgZUFCJsd6CbAjdhaiZ4xPmpAPckAcLWUWda WCFEvqJJluWDMlp89ISvJ6qhXeCPn8usCEpWJfD/PXUOufDL7GKfbmwW3jDrT/srBs2mfQSX/R uZARTS7Zyt+eWrqbvicwyu80mTluAG35W8hn1+t35CqmddLaLd0iGt7iqJI1t67q1ckE2fKQg6 Xs9xXU0GPB+IYRryo4OJAJp4NHQrDF8/1FQkEGjGaLa4Vw==; 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-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=o2FuGrU7QhTh65T8r+RIq2kPs4SKEepUEZ1IXhJEX3c=; b=TmbyIVWrbz/D8QB9rEhc2hMpj1 18oBDc/xbkwye8HJkWh3pjPPfyx4KG/yGhYzTJt4bE326NJx/uvQvRQ+wBqndXEIQlzEQek+IL7KK 99dvJ5uvms8FfVYGSTxq55OvKk8ftZ76+H4vjDenGdC2hQqwC0ObyQtmM04YMs9/vmfhPY2XtORHp SSDGT07zcWMYhCTQS3NvmgIDAEXUjfbMNTPvk3r8poSII7j1O45riLhtP1iZKgoGez1rH9dz5jbBW Ar1YYMPSZVOJdjjAml3AG7+TvCuyCcx0tUR5rSRxx9q9Ey87dcOIGwnBBj8FHf3VM9iEwxT7xbrfz iV/Ohpsw==; Received: by zero.zsh.org with local id 1otFTt-000DRE-BQ; Thu, 10 Nov 2022 21:53:05 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yb1-f178.google.com) smtp.remote-ip=209.85.219.178; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-yb1-f178.google.com ([209.85.219.178]:33723) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1otFSt-000Chr-L5; Thu, 10 Nov 2022 21:52:04 +0000 Received: by mail-yb1-f178.google.com with SMTP id z192so4014737yba.0 for ; Thu, 10 Nov 2022 13:52:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=o2FuGrU7QhTh65T8r+RIq2kPs4SKEepUEZ1IXhJEX3c=; b=G97nVbJvGESJf6kqICV6TgPj1DA29DLZNcpF1e/jSd+lSFQxF2LhAdo0whzZ7FbGUm xm92tKvmBDgIl+DzFJ7W0Nebsx7cSPeRCSYUteDciPhzAY6CtWZ7hjWvSI8D/YkqVuHh TQ1K31oK0/UdUBdG93VHnQhhmGQiqUaegy1UnSWdGy0WEbZ1cWyLYN/f3ykb8e/pCvK2 Qh+nHcQ61cSzBpxns5HZtC/bYrkbx6pZC1dFnmI+P+o3Xb6nKWJe3swy4fuDXiFW8H9w MwCZPaIkYRDlHMlfFEWIxO9A8JYLNzgVV9WuR8QwWaQwum5XVFnUBVdKgRXI2vS1n+ty 8m5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=o2FuGrU7QhTh65T8r+RIq2kPs4SKEepUEZ1IXhJEX3c=; b=7+5n1L6cZ9XoB2uml3gSaGXyicvxdmDU5EjRb24B3PHtvMqjmQ0/dDl9mLCL7OOQtY H/WTLTbkGYUXUkr+r5F388A7iz8rdb9mTQecBTvha3T8d3EYpaZi2lwjbOqGw3dp6PX9 YTCSw7subT8waa/gWiCxXyOjLcHSnAF7LxRvGQUVG3BVBIKsG5+bpGesEcs2pb+wk9Jb FIzvPfZTC+fIDq/+VDlKs3RylFLeKrbV8/dyBW/LNeODdKQmB5oGJXtT19wdVBD5Fc7x yWLh+0IvfuEHvFcrZWnCX6+jVQcaaUszxhXe/nSw2Wk/aZtBX20NmcaImwpw8N0M26KR B6mA== X-Gm-Message-State: ACrzQf1f+0ArYyrE+yQAy6hDvKO7rJuuVUAODqEJO2QjY52C0h5Ttxvv cBPzPW6Y9xq0lBNGsq1caHLB2aJ8/ZztIQqhAkvBhQ6n X-Google-Smtp-Source: AMsMyM594aI8a9Hr7SFhlXan0GW5AGQiOpbOlg0lqYuYRM4fgU0EUysYVuiiE/wT2FCFH3IC0R8dlGZTOyH8T3uK9bs= X-Received: by 2002:a5b:ec4:0:b0:6cf:c1db:b90e with SMTP id a4-20020a5b0ec4000000b006cfc1dbb90emr47461686ybs.449.1668117122330; Thu, 10 Nov 2022 13:52:02 -0800 (PST) MIME-Version: 1.0 References: <549715c2-8b36-8b7e-e3ac-cac02f43dd0f@eastlink.ca> <0a7dbe0d-1554-269a-f420-bfe320c7c838@eastlink.ca> <6d7ba212-be9d-6bb4-f5ce-9a796032ade0@eastlink.ca> In-Reply-To: <6d7ba212-be9d-6bb4-f5ce-9a796032ade0@eastlink.ca> From: Roman Perepelitsa Date: Thu, 10 Nov 2022 22:51:49 +0100 Message-ID: Subject: Re: coloring substitution seems to eat next line. To: Ray Andrews Cc: zsh-users@zsh.org Content-Type: text/plain; charset="UTF-8" X-Seq: 28364 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 Thu, Nov 10, 2022 at 10:42 PM Ray Andrews wrote: > > > On 2022-11-10 12:22, Bart Schaefer wrote: > > > > Most of the time you want the parens when assigning all the elements > > of an array at once. You should not use the parens for anything > > that's meant to be a single string (or number). > Slowly I figure out what's really going on and don't have to rely on > rote copying of syntax. > > local MATCH MBEGIN MEND > > which should never appear except inside a function, and should only > > appear at the beginning of the function and not inside a loop. > Heavy duty diagnostic stuff it seems. > > $~foo (or ${~foo} means that the value of $foo should be interpreted > > as a glob pattern rather than as a literal string. > > Ah! When you type it in there verbatim it seems to always be the > pattern, but as a variable who's to say that the intention is? So some > way of making it explicit avoids semantic confusion. That's robust, I > like it. One more little thing: > > > string="${cc[$aa]/*(#i)$filter*/}" > if [[ "$string" ]]; then > cc[aa]='' > else > cc[$aa]=${cc[$aa]/(#b)($~zsh_case${filter})/$'\e['$color;1m${match[1]}$'\e[0m'} If you look back, you can find in my answers a way to: 1. Remove all elements of an array that don't match a pattern. It has this form: array=(${(M)array:#pattern}) 2. Perform a replacement in all elements of an array. Like this: array=(${array//pattern/substitute}) Perhaps now you have enough familiarity with the syntax to see how it works. You can save a tremendous amount of time by reading the official guide and the reference. Set aside an evening or two and read them from start to end. Exploring a language as a science project is a great way to get started but at some point you'll become more efficient by reading the blueprint. After that the language becomes an artifact rather than a blackbox. Roman.