>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/*