Actually replied to the mailing list this time... >Have you considered just not unsetting caseglob? Brilliant solution. "Doctor, it hurts when I do this." "Then don't do that." As for the compliant version, here is a much more "polite" version which also avoids the awkward checks if lock != NULL (at the cost of reformatting O.o). /* Check for search permissions. If we don't have them, get out. */ if (access(fn, X_OK) != 0) { return; } /* Check for read permissions. If we have them, try to open the directory. */ if (access(fn, R_OK) == 0) { DIR *lock = diropen(fn); if (lock == NULL) return; while (...) { ... } closedir(lock); } if (subdirs) { ... } % chmod 111 .. % echo $PWD/* /tmp/inaccessible/a/a /tmp/inaccessible/a/b /tmp/inaccessible/a/c % chmod 000 .. % echo $PWD/* zsh: no matches found: /tmp/inaccessible/a/* This matches the POSIX behavior of requiring parent directories to be searchable, and is a little more respectful to filesystem permissions. On Tue, Jan 12, 2021, 8:58 PM Devin Hussey wrote: > >Have you considered just not unsetting caseglob? > > Brilliant solution. > "Doctor, it hurts when I do this." > "Then don't do that." > > As for the compliant version, here is a much more "polite" version. > > This matches the behavior of the POSIX globs: with a non searchable > directory, it returns no match, but doesn't require read access for parent > directories. > > DIR *lock = NULL; > > /* Check for search permissions. If we don't have them, get out. */ > if (access(fn, X_OK) != 0) { > return; > } > /* Check for read permissions. If we have them, try to open the directory. > */ > if (access(fn, R_OK) == 0) { > lock = diropen(fn); > /* Error */ > if (lock == NULL) > return; > } > while (lock != NULL &&... > > % chmod 111 .. > % echo $PWD/* > /tmp/inaccessible/a/a /tmp/inaccessible/a/b /tmp/inaccessible/a/c > % chmod 000 .. > % echo $PWD/* > zsh: no matches found: /tmp/inaccessible/a/* >