Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: NO_CASE_GLOB and unreadable directories (Episode VI: A New Hope)
- X-seq: zsh-workers 47866
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Cc: Devin Hussey <husseydevin@xxxxxxxxx>
- Subject: Re: NO_CASE_GLOB and unreadable directories (Episode VI: A New Hope)
- Date: Sun, 24 Jan 2021 16:52:45 -0800
- Archived-at: <https://zsh.org/workers/47866>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2021-01/CAH%2Bw%3D7aLB%2BwHaZe%3DdedrmdVxvqQjMMk4vFz99rKCAadtNzgbqw%40mail.gmail.com>
- In-reply-to: <CAH+w=7Y5UQDd7Xn6g9MR_oYtDFw8S-2WpX7xEehPZ9y47=ex8w@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAEtFKssJf-cN_EM+=5_10seY58jqALV-YH8+z5+Lm-04v493Nw@mail.gmail.com> <CAH+w=7bn8JYPx29LPGnT4ughEt-z+-rUokUz739foP=JCY9B7g@mail.gmail.com> <CAEtFKssJVz9mr3vA_vY77m2bsrXWBKHz1qgv83jzeY0jLXzPjQ@mail.gmail.com> <CAH+w=7aoaGhVCqZQ6K+z0HqJg3agOav6bh6M_9pg464aAC+htQ@mail.gmail.com> <CAH+w=7Y5UQDd7Xn6g9MR_oYtDFw8S-2WpX7xEehPZ9y47=ex8w@mail.gmail.com>
No comment on this at all? Some additional remarks below.
On Wed, Jan 13, 2021 at 9:57 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> 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.
There's no practical workaround for this that I can see. Without
reading the parent directory, on a case-sensitive filesystem we'd have
to attempt to chdir to every possible combination of upper/lower case
in the pathname.
> 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
I think this is a real bug, but it can't be fixed without breaking the
case in which the current implementation finds AnyDir/ in the absence
of anydir/ (assuming the parent of AnyDir is readable).
> 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)*
This is probably how CASEGLOB should have been implemented in the
first place. Note that the documentation sort of implies this
interpretation:
[nocaseglob] the presence of any character which is special to
filename generation will cause case-insensitive matching. For
example, cvs(/) can match the directory CVS owing to the presence
of the globbing flag (unless the option BARE_GLOB_QUAL is unset).
There's no mention in there of what happens when the path is more than
one directory deep.
I see these possibilities:
1) Do nothing; Devin's case is broken by design and termux needs to
come up with a solution that doesn't involve NO_CASE_GLOB.
2) Adopt (a CYGWIN-clean variant of) my patch from workers/47832, and
accept that some current usage of NO_CASE_GLOB will break.
3) Add a setopt (CASE_DIRS ?) for the current behavior, and merge that
with workers/47832. I haven't yet worked out how to avoid having
"setopt nocasedirs" imply the effects of "setopt nocaseglob" ...
perhaps name it CASE_SEARCH (?) and simply leave the implication?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author