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 1232 invoked from network); 11 Nov 2022 22:40:02 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 11 Nov 2022 22:40:02 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1668206402; b=AuwSluHMbRJCXWrN7ECu9ZBaZNPWvOtXGcVWwSXMjKsnt6stWdDZTYAM4t/xPQOPP7Q9oM6GcS EuZhydgah0puoDQFPgeS0xCSA6mZrlxghYJafodty3nelBPRmNoY5CHfqhtWA1KmMvHfB6phsJ YnQTGK9BqnWsNIQSN1weRdWFb+mSdmMWN7zH7ICM94W+bplLlIzPmXlGk1dywHnou2G2SbdU21 r53Nvw9fsftxgn6/6N2bjLJ9msSROsx9QwtAciQpycPTuoY3axKe3MasemtzTA3z97GopOeEf2 1fuaYbQtwVFjFa7jquasR8G8cZ56UeUVjYIhzJQZ06Uqyw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yw1-f172.google.com) smtp.remote-ip=209.85.128.172; 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=1668206402; bh=6RH3JFp3JBGBo3xCmWaFe1A9Yynuik/NtSElsv7lR7Q=; 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=JkHoeKQ4O1kxCQ+Q5I4LdSv+2Ud1dywk3fo441WsiYIaDKcmLKn+6NNI++/VMjLgHlo8HsUtGJ e3RXl/5aWK059k6DzO3h6vkZOMrmSKZDKLaozQ1W/4ys2Zw2RJTp0fSEOYj0t/petzi1RUVS97 s3yiO8nhhgGjY1yVeSeL9Vi8wajWbdx6V8kQuMSgClVmPt46sTxtjiM8ZKBa2cHwMXXvMrTsHe e7PkZP2nIJH7OlwAILqZs3A64dDnt0LCyYjbTIDAz7/KjHEKc3i/qEGzMUVqAMiZOdViwfHSGX mzz0VcA5bf7TIZFkfddrZAZe4zYHN5bDvNeQWaGR3CddLA==; 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=QEWJVyMDVH9qjx5got8MHra44/vBIKRVKnOWH2iambk=; b=dur0mtGkidveNG47OEc2ZlARZN mLnJcoO0cSsaUQ8/UMKgLXOA2rmSxYodY8irxQ2xroEFxB10RI2QiL6fnvP+waf9pfMt3G3uIuZMV 9HzsCq2s4U0h/knESoej+l/Ds9dpxMQ7vKvMinB0lfPImE5RdqMD+yk00OnW7bLYZ3J2IiFe30GPK 0FS0KDkR9QMKqYIKOkK36NrcNCzEUM7s5C6n8FWT3WH1UYrvEGERJ76sjVCF2OLMeq7LjnJcf7et+ OAnw8c84gdwmzxXiqsBOc01JGdH8ccQoxt+YQcnP0VqgQAWh/39/mqtvt3LRkayQxhBENGV4pps5M Fxa/ZPlA==; Received: by zero.zsh.org with local id 1otcgs-000GLE-JP; Fri, 11 Nov 2022 22:40:02 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yw1-f172.google.com) smtp.remote-ip=209.85.128.172; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-yw1-f172.google.com ([209.85.128.172]:34513) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1otcgP-000Fe6-SH; Fri, 11 Nov 2022 22:39:35 +0000 Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-367cd2807f2so56264767b3.1 for ; Fri, 11 Nov 2022 14:39:33 -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=QEWJVyMDVH9qjx5got8MHra44/vBIKRVKnOWH2iambk=; b=AfbKdJAlDAX5wwQsLsP/+zTbNpo8pkO6ohS1GehgcGyZCEih2wDSMj4qwMG7KgUnIR X8Cpg2/alDk4dJwWlkTDOIlNBX5vBaZmz8H13vIc7eFLIgoWgUu7UxHjmXzJ3v0839by u8FNZQAEaF/njPUJbtWpxrTE40az9rOFp6ktc4PkVwQoVbYF/Jg2gT29p/s4S/MF/nxK 1bqk2V86qE8zcr57FtoGRmnhZPYRoXH1jxXVqmQW+2bFLTIyf2M3eaq/CF/RuCuoN94x p6PC1Le51UgoPfncypzExfg3NBkXX1kFtq8O6RWr4FcBCBjOBO822TY84th+EyhBFWft 0miQ== 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=QEWJVyMDVH9qjx5got8MHra44/vBIKRVKnOWH2iambk=; b=OT4Uv3JX2LTnwIUBRWynBAglMGPFHjBPfwlnOjCkHGdp5HFArvUPn8oi+JFQcdCNZK DPY3VHwL45K6+EtJ8f5Hg1zbch+qNHAbgwz44h8j7Qb01wrTkvU70GlN/st7Fc3WKd9M ObcptH7lSff7RPP3kBpu44gQcBSxqQrNTl9qLEDi2ucNAJmxQw/xfcURNjqR5UReFQxp Zuk4cIUaV/KDQJdwn7tFQETZ6IMu94AdxvlYHeD2Tbja75xruayxk9k5m+CMHTwpWhpN HyxR/cYVBYfG6P6/liuiUhqAl3bIzdKAZFrok5FCxyY3cOZzc7RUzqM74P82TmMu8qaQ AO3w== X-Gm-Message-State: ANoB5pnLMUSWKxl8MDjNJdgsFIsSU5B5LaFCdci3mBFDh2pnDOaZA5ky rTl3XpVmVIgLc1HM9AHKfBmsZqG6JjnWj0nwRoM= X-Google-Smtp-Source: AA0mqf7Jgg7aXWOTEj8Ls4tpKwdqift7OaheRX24g15fTnRe6PcWK3Th7B1AdQPIGiQJcmvc1pGvt4VTN/VsQgyHdKo= X-Received: by 2002:a81:6dd0:0:b0:36b:2db1:925b with SMTP id i199-20020a816dd0000000b0036b2db1925bmr3825387ywc.434.1668206372609; Fri, 11 Nov 2022 14:39:32 -0800 (PST) MIME-Version: 1.0 References: <5454df12-02c6-75b5-e552-c486e231183c@eastlink.ca> <1b44b09a-ebae-a45d-a19d-c83e1ce68f65@eastlink.ca> <6042df79-449b-93fc-0d2a-dc990b552c70@eastlink.ca> In-Reply-To: <6042df79-449b-93fc-0d2a-dc990b552c70@eastlink.ca> From: Roman Perepelitsa Date: Fri, 11 Nov 2022 23:39:21 +0100 Message-ID: Subject: Re: coloring a substitution To: Ray Andrews Cc: zsh-users@zsh.org Content-Type: text/plain; charset="UTF-8" X-Seq: 28377 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 Fri, Nov 11, 2022 at 11:25 PM Ray Andrews wrote: > > On 2022-11-09 00:19, Roman Perepelitsa wrote: > > Try this instead: > > if [[ $scope_msg = 'BROAD' && $dirname = (#i)*$~1* ]] || > > [[ $scope_msg = 'Case INsensitive TAME' && $dirname = (#i)$~1 ]] || > > [[ $scope_msg = 'Case Sensitive WILD' && $dirname = *$~1* ]] || > > [[ $scope_msg = 'EXACT' && $dirname = $~1 ]]; then > > > That's in place Roman, works identically to mine and I'll keep it on > your say so, but what are the fine points on why your lines are better? These four cases are {case-sensitive, case-insensitive} x {full, partial}. Moreover, the implementation of every case differs only on these two bits: case insensitivity is always encoded as (#i) and partial match always as *..*. The only bizarre thing here is the names of these cases. They don't reflect the simplicity of the code. The code is in fact so simple that it's not obvious that it needs any cases other than 'EXACT': $1 can have (#i) in it to make the match case-insensitive and *..* to make it partial. It can even have the asterisk only one one side for prefix and suffix matches. > if [[ "$scope_msg" = 'BROAD' && $dirname = > (#i)*$1* ]] \ > || [[ "$scope_msg" = 'Case INsensitive TAME' && $dirname:u = $1:u ]] \ > || [[ "$scope_msg" = 'Case Sensitive WILD' && $dirname =~ $1 ]] \ > || [[ "$scope_msg" = 'EXACT' && $dirname = $1 ]]; > then Can you similarly describe these four cases, the way I've done in the first paragraph above? I cannot. All four look uniquely different, so the inventive names (BROAD, TAME, WILD, EXACT) almost look justified. Roman.