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,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 4000 invoked from network); 14 Jan 2021 05:58:16 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 14 Jan 2021 05:58:16 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1610603896; b=z+Z1cgwRUAOHu4NY+KZtLlgArH/mgM4J/au1Ma+2IJffDUagXjTmXdEIg6ZB3MLvz5Mib4eMia MwUMPChY1Vtr+LoJpEAjHtBZMe1v5HPefSkKwARppahMmcQKmtQumEKmXjXbc3SAxHbqGlTTe2 TBNQUOyj1pp/YB2DtmDdnNLNp3fqz7q6IheXxKlNWDAvYd048NFLUuU6/OyeqeasQ4NM66eCz+ Fw6ZngIUdXcvhLNx/LrsZoJkCYa2F25iSVa0Q1nbn90t5I6Zwhg+N9jPKFbP23xUvZp+fiqgdN pXtz2XSAYOqonSOfaGh75HA8NNCPWIs9YiNvTJk54beVUw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ot1-f50.google.com) smtp.remote-ip=209.85.210.50; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1610603896; bh=Octf2qm/HVa18vihx8DfL9QvXvju3b5Ls2JJkc5TrPI=; 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=f3f6ezhXrJa+N6z+HbqsTE555KDo4bEm9os7f90+wemUMGpdtEkl8O60jMNizPkBCvnzf2ZZk4 RWG7OcIBAOmOCZ0C+7dCQl7QavBdPjv6DbQAJoY/rv6k/SaumSWLvxSSoXxG6wJCvpAv9xejPM V6mhvk7m5/kdhTomn78/vrJL3SFn+CEitYeJ8ys6x4qykWbPUgek6HWMd6bGpj4JHqdLsjAXef Yc7MmYvE/C/cpqMQP0xtd2fOEadnPaO8DTNy8fd7roucR3M5vS/wt4PIQh2eCKaMeJdHngBsbz R2xGMNlcnj44qF3UIoPsyDZRTlfX6FjxPHa8iW/Rl3Q9uw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; 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=v2JnZmUweLx8Dykwz8m6ozTTzusS6Sf8G96cmMDFM3c=; b=hf1WbFtaO9o3MDmqEqhpY+7snN 4ghSiZTTGRCg4Mmwa1xXUZV8VJD/fvRICdGZj5+pZnE0cyWrfkp8ytBRS/VNHyJpis8sfHkUtv1F9 mAJKdGz5+Q118Pn9uF4e4K3jKyAJur9c8Tepwl7ZsHgWvPJFnWz913Wa8s05F5IRyiPjd1oxWWhPK pchP7IUhmZJuh9/uZCbNvrI6rzwyPRj9RgPAaYby1q0JWBJp0a1cPYMlxZclkii5aHTdXFeotwjll M4Qh4sfFXbPQrcfrPzkWAmAKPvKzkc7wqbPc6eSFa3qMLNlPwUj62zw/oxnSr5Cp7lNDIXioq9ZdM ygKkRRng==; Received: from authenticated user by zero.zsh.org with local id 1kzveA-0008BO-Te; Thu, 14 Jan 2021 05:58:14 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ot1-f50.google.com) smtp.remote-ip=209.85.210.50; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ot1-f50.google.com ([209.85.210.50]:46182) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kzvdq-00082Z-RP; Thu, 14 Jan 2021 05:57:55 +0000 Received: by mail-ot1-f50.google.com with SMTP id w3so4213893otp.13 for ; Wed, 13 Jan 2021 21:57:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=v2JnZmUweLx8Dykwz8m6ozTTzusS6Sf8G96cmMDFM3c=; b=XkRCK6JGg48UjMS0Dq7dXG7pYtVHLjPIcJAUeOBTo+70CTOcSCtZHRyjrJe2ox1q4Z OQpdOOA4IHIqkHA5EMqtOf++yAquyC7o3EhDwCKSHlw/rfF+HNhWHcWXYcgbdqaD3Gxv /iOyEDboQkbCJtJmhmCSdO8jy6pmbYHa8b8weSVUe93TUvEX334ddOJA9wM6fGK27w/I J8MedXv6M/S1ydHpoCiRt7nmSRKH89/3W2PwZJM0mY6f9hgxIElXHtiXGfy7Sc5Ud6td AJLQK+Lf1rILMGbPdDsU7oFUiTO7ltO6cN5qe8iTz39OxTVmeeOb64e6iofXvsMgkX1Y khiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=v2JnZmUweLx8Dykwz8m6ozTTzusS6Sf8G96cmMDFM3c=; b=Pc5qyWlkdVJmlcQAQWVRzG0RkbaBSi829aGMjJPYfixWj76JIKemYPC+N+srn+TPNa mX7z4ixGK78Xln76wPAgJFe6DgVSMiHB2pZr+22JQjAhYiGky1KrfEv1ZJHFG30G7OkC gzXiVNgyHZgT77RPTBiy7L/UE4Y+lbeT8ect7RZsyZJAX8PSkpChDGqrJb4Ovkw/K1LZ nA4n748NkvV4pDpCC70sxGtVDdDzjY1r7q2xmz0yKwZaaGWgISAuZFKWbMmZDA+6BiHQ Q0dI369bpT84mlX8Q6v6BzL1wE9XOAwvm9wtn0AMfQJnSW1YbickqbKYNW9luP4MQSNH weWw== X-Gm-Message-State: AOAM532VqgZ/d7yrC0V2ASkHZmqgNDeK2yRpBopHwkN0jLVqeJKplnNj 22MtU0f4Aur48sxNWu3XRaVi13DlYNPlmikhRvGVTnxALmcI93FL X-Google-Smtp-Source: ABdhPJzwjWA69O3qX3LVSFTfiUR5/xwRSkVsZMRkkqqy/0wiOB9Plg1bRjKf79QJTUp77xjj8vGeUPdzmbPHgDgOZ5E= X-Received: by 2002:a9d:4c8d:: with SMTP id m13mr3618513otf.229.1610603873028; Wed, 13 Jan 2021 21:57:53 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Wed, 13 Jan 2021 21:57:42 -0800 Message-ID: Subject: NO_CASE_GLOB and unreadable directories (Episode VI: A New Hope) To: "zsh-workers@zsh.org" Cc: Devin Hussey Content-Type: text/plain; charset="UTF-8" X-Seq: 47829 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: On Wed, Jan 13, 2021 at 8:04 PM Bart Schaefer wrote: > > On Wed, Jan 13, 2021 at 4:28 PM Devin Hussey wrote: > > > > Case insensitivity should not change the output due to file permissions. > > [... unless (?)] the filesystem is case-sensitive. Why should > (#i)file not be the same as [Ff][Ii][Ll][Ee] ? I'm still of this opinion, but I now think zsh is [conceptually] applying (#i) in the wrong way. > The actual problem is that PAT_PURES is never true when NO_CASE_GLOB > is set. Effectively, NO_CASE_GLOB turns the pure path /data/data/com.termux/files/home (to stick with the original example) into the extendedglob pattern /(#i)data/(#i)data/(#i)com.termux/(#i)files/(#i)home which means every component has to be compared with pattry() rather than as a literal string. That in turn means that every parent must be readable. It further means that anydir/* becomes (#i)anydir/(#i)* which could be construed as incorrect, because if there are two directories AnyDir/ anydir/ that pattern will return everything in both of them, even though only the lower-case version was specified. (This actually mentioned in another of the github threads to which Devin linked.) What's wanted in Devin's case is for (#i) to apply exactly when there are other pattern characters in the component, e.g., (#I)anydir/(#i)* which I believe is expressed by the following patch. This is not yet suitable for folding into the master branch, because it is a significant change to the current zsh behavior (and because there's some #ifdef __CYGWIN__ in there that I can't test and am not sure what to do with). For example (in the zsh source tree): unpatched% setopt nocaseglob unpatched% echo src/module? Src/Modules Whereas: patched% setopt nocaseglob patched% echo src/module? zsh: no matches found: src/module? patched% echo Src/module? Src/Modules There are no tests of NO_CASE_GLOB in Test/E01options.ztst, but all the tests of (#i) in D02glob still pass. diff --git a/Src/pattern.c b/Src/pattern.c index c7c2c8bea..9869db5ef 100644 --- a/Src/pattern.c +++ b/Src/pattern.c @@ -509,10 +509,7 @@ void patcompstart(void) { patcompcharsset(); - if (isset(CASEGLOB)) - patglobflags = 0; - else - patglobflags = GF_IGNCASE; + patglobflags = 0; if (isset(MULTIBYTE)) patglobflags |= GF_MULTIBYTE; } @@ -632,6 +629,12 @@ patcompile(char *exp, int inflags, char **endexp) p->patmlen = len; p->patnpar = patnpar-1; + if (!isset(CASEGLOB) && !(patflags & PAT_PURES)) { + /* Special __CYGWIN__ handling needed? */ + p->globflags |= GF_IGNCASE; + p->globend |= GF_IGNCASE; + } + if (!strp) { pscan = (Upat)(patout + startoff);