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 21468 invoked from network); 10 Nov 2022 08:09:16 -0000 Received: from zero.zsh.org (94.142.241.90) by inbox.vuxu.org with ESMTPUTF8; 10 Nov 2022 08:09:16 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1668067756; b=kv//4KPD3X2UGwiqZF8FZDY0X1lO63hEFWBtzJyrN6k9Yqd/sVJQ0g0rwwatlNFduLZNWgKeyo vRLgR8eFf4jhtLYTRvmEV1vmkFe+xlrPWzfQGkmwDY3IVG9tgY8UCINuDkOoj9KXqvTaV95Zeg ix7/ZL0bmTLr4wXSAMrpMdq9/PsGHCO6UpJFgKvkSgRcsdiiweYZG4X6SnY3GJ1H1GFe2k2lWb YvIHCOBvRNP3yXbZXwr0kK/x9S9jtjHgyGiCr68b3K4bz3WWY1bQ9w8cuNa+4WPgdeYsaFIpI7 HbZSDf07qsKdd7/vzEOv7tO96u6cMA6PPpWUEDSWPOsbEw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yb1-f175.google.com) smtp.remote-ip=209.85.219.175; 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=1668067756; bh=fSqssP2w3XbYpTlK4h5Lb66+1tQYzPx0AygyYReeQg4=; 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=VY94gQVZ1+JIOF9alUtlZsVJyYzVTCsUD2Srn8vOAJh5lmH/i49vls2kN4+6pEnzF4y3S2NC1Q EtYdR2BiW8GWmqyYDAoDJbv1xC3YU4BOS2cL/FU8D89NaWqgRYvRhApiB31djrA2LpFy7y22uz LwmEv0mcx7XLyO/jXzT1I50FhBvOqriCk+tKDJow7Kop3OAOLqiy3EVytB7v6sAKWcJRtyX1N8 sAujSwfIbCTk6XK1x3yMqiqFTGT3essLBbxRv/yGYl/1iuUAiTTvTBcqU8IikMn7BxWbKmXZHN pLjQG2MaGN2DwmPli0/KkC2pKuqg6RiHJg+x838+Lvpujw==; 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=H2OvyDKWzlAmHhmrYgz03Z+Jcg3YHYm6/ptiqpdT930=; b=MelYYEH9j6oCT4v1ec2x/TiKcu qHKSuUs0MtJGAB2323Ixgh1fqLqCj1t2ATYYObOqaWDArPnUPJkbUkVVVsx5uceGMJBbzJQBjHMfo waPpy55XeILebhShznCBdhiZbA7s5+mcUpMqoPVnGuf5CK2nVe/NpJ+EDfp4xhjh0Gg3rcVgwZr5D kGDPxh1KBqc4JpHVsudy4XvgxlNFKBXjtXbM20GDu15CtdLl/4113UVWynEvq42OHGYsqfTBd3NDq Cz2VJ8kfaIsuy3GbDseEhoPXqfkq3086LbhPzyjVfnehSUeGg1FjBnxrYvPoo52JcRl3xSzMX5qh7 KAa9csiQ==; Received: by zero.zsh.org with local id 1ot2Xn-00079l-QG; Thu, 10 Nov 2022 08:04:15 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yb1-f175.google.com) smtp.remote-ip=209.85.219.175; 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-f175.google.com ([209.85.219.175]:41871) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1ot2W8-0006RR-BS; Thu, 10 Nov 2022 08:02:33 +0000 Received: by mail-yb1-f175.google.com with SMTP id g127so1439198ybg.8 for ; Thu, 10 Nov 2022 00:02:32 -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=H2OvyDKWzlAmHhmrYgz03Z+Jcg3YHYm6/ptiqpdT930=; b=HRgiSYz4II87fErUL/hn00pNaXXVqlY5CfmbQjaz77p8XBLd+S8mxz/cpCXTiA1lnW HE7BefU/yWlrYOGnZR0gyQcrWb8cm1+w7YQwQEbdDLwVp4t14sPyaXNNt0I+AXJ7CCve 8vp30AioX6mzAkGxtT+RWbwgaPXllNcfaq+EqmcjdFKE00dKZ6dH+C3qJ6PXELiLayB4 +BCCuI5WjPwm7eV39leaS0b+9tmy7TuCy4FMoGxJHzdAR568P3zfjx1vRsSKVypjpUeK 0euoRvB2YgzfCwyfCfJUvMf5auI7YJoCaQr0ciW2pt+rBJ07JFfi4mQMpRWWqidwKpK2 YZgg== 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=H2OvyDKWzlAmHhmrYgz03Z+Jcg3YHYm6/ptiqpdT930=; b=cjugFBJaiUFWxLbnNDDUk/Mzcz8m1S/kJ0QAirIBxfQ9NLEB/uzc6kvMKnhrk8brNd R+Lu2yK832tnQwBrmGs37viZozgWLp/hos3z1YI91ZlbRhNF3ayBhi+YoP2gRvkEZKGN tJM+v1sqVFJ6hWO+u2tnXYHXda40xck4qATh7kPnzGEEJ45cF4I61WkyyA5HK0n+tB/1 AyFTAkviTUYclVZUayQFNw8k7dZ7PDrFgiDCQv3IXk6FLAugPK7WYuzsYPILKRG6SWgK fPFAxoK8SP9okI03MR4aMGLzwlJnrq8ZDXOk8n9X8zDw4pGZd2gcSrRcpKpKqqR+hTbg XTOQ== X-Gm-Message-State: ANoB5pkpjhmAGesq9HcGX0SyFEyvp0gjD5bDeyLRM8z9xTV0vGWgCv+M JCIcsA24WNNkpzhDyH2T4mRoQ/6qm3Ej65CghHI= X-Google-Smtp-Source: AA0mqf46p7uSNOeQxwVtZ1NMAMA/lMpRimGgrWknb7Apm6m1MSMRIqwbpnZxJN3z2xsAsOjXLroBwAohPBmI/NsWCXU= X-Received: by 2002:a25:d655:0:b0:6d3:7c5a:9d39 with SMTP id n82-20020a25d655000000b006d37c5a9d39mr30074518ybg.175.1668067350385; Thu, 10 Nov 2022 00:02:30 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Roman Perepelitsa Date: Thu, 10 Nov 2022 09:02:19 +0100 Message-ID: Subject: Re: coloring substitution seems to eat next line. To: Ray Andrews Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 28355 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 1:44 AM Ray Andrews wrote: > > cc[$aa]=$( print -r $cc[$aa] | sed -rn > "s/($filter)/\x1b\[$color;1m\1\x1b\[0m/${sed_case}gp" ) > > ... that's the sed version working fine. But this: > > cc[aa]=( > ${${cc[aa]}//(#b)((#i)${filter})/$'\e[31;1m'${match[1]}$'\e[0m'} ) Differences in the second version compared to the first: - aa instead of $aa - slice assignment instead of scalar (almost certainly unintended) - hardcoded (#i) instead of $sed_case - hardcoded 31 instead of $color - $filter treated as a literal instead of regex Given that the second version works without errors, I assume that cc must be a regular (not associative) array. This means you can replace the whole loop with this: local MATCH MBEGIN MEND cc=(${cc//(#m)$~zsh_case$filter/$'\e[31;1m'$MATCH$'\e[0m'}) Here's a test: () { emulate -L zsh -o extended_glob local cc=(/foo/Zsh/bar /baz /ZSHzsh /zsh-zsh) local filter=zsh local zsh_case='(#i)' local MATCH MBEGIN MEND cc=(${cc//(#m)$~zsh_case$filter/$'\e[31;1m'$MATCH$'\e[0m'}) print -rC1 -- ${(qqqq)cc} print -rC1 -- $cc } > /aWorking/Zsh disappears going in but seems > to be there going out , but not colored You can debug this by printing all relevant parameters. print -r -- "going in: $cc[aa]" typeset -p cc aa filter ... typeset -p cc print -r -- "coming out: $cc[aa]" After that you can reproduce and dissect the issue in isolation. You can also ask other people for help and give them everything they need to reproduce the problem. Roman.