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:
parent
0e0f1d53fe
commit
149187706d
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user