ash: if using libc glob(), skip it if no metachars are in word
This saves making tons of pointless stat() calls function old new delta expandarg 888 921 +33 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
474ed06c39
commit
d4f3db9427
15
shell/ash.c
15
shell/ash.c
@ -7047,6 +7047,21 @@ expandmeta(struct strlist *str /*, int flag*/)
|
|||||||
|
|
||||||
if (fflag)
|
if (fflag)
|
||||||
goto nometa;
|
goto nometa;
|
||||||
|
|
||||||
|
/* Avoid glob() (and thus, stat() et al) for words like "echo" */
|
||||||
|
p = str->text;
|
||||||
|
while (*p) {
|
||||||
|
if (*p == '*')
|
||||||
|
goto need_glob;
|
||||||
|
if (*p == '?')
|
||||||
|
goto need_glob;
|
||||||
|
if (*p == '[')
|
||||||
|
goto need_glob;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
goto nometa;
|
||||||
|
|
||||||
|
need_glob:
|
||||||
INT_OFF;
|
INT_OFF;
|
||||||
p = preglob(str->text, RMESCAPE_ALLOC | RMESCAPE_HEAP);
|
p = preglob(str->text, RMESCAPE_ALLOC | RMESCAPE_HEAP);
|
||||||
// GLOB_NOMAGIC (GNU): if no *?[ chars in pattern, return it even if no match
|
// GLOB_NOMAGIC (GNU): if no *?[ chars in pattern, return it even if no match
|
||||||
|
Loading…
Reference in New Issue
Block a user