Interpret correctly the glob(3) return value.

Previously, interactive commands specifying a non-existent file or
directory used to display an "out of memory error".

MFC after:	2 weeks
This commit is contained in:
dds 2005-07-21 16:12:35 +00:00
parent 0e0f1d53fe
commit 149187706d

View File

@ -365,8 +365,14 @@ getnext:
snprintf(output, sizeof(output), "%s/%s", curdir, rawname);
canon(output, name, size);
}
if (glob(name, GLOB_ALTDIRFUNC, NULL, &ap->glob) < 0)
switch (glob(name, GLOB_ALTDIRFUNC, NULL, &ap->glob)) {
case GLOB_NOSPACE:
fprintf(stderr, "%s: out of memory\n", ap->cmd);
break;
case GLOB_NOMATCH:
fprintf(stderr, "%s %s: no such file or directory\n", ap->cmd, name);
break;
}
if (ap->glob.gl_pathc == 0)
return;
ap->freeglob = 1;