diff options
-rw-r--r-- | shell/ash.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c index d617168b9..ecd2146e4 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -7047,6 +7047,21 @@ expandmeta(struct strlist *str /*, int flag*/) if (fflag) 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; p = preglob(str->text, RMESCAPE_ALLOC | RMESCAPE_HEAP); // GLOB_NOMAGIC (GNU): if no *?[ chars in pattern, return it even if no match |